[net.bugs.4bsd] A speed improvement for recent versions of 4.2 BSD f77

donn@utah-cs.UUCP (Donn Seeley) (05/02/85)

This fix should only apply to people with recent Berkeley or Utah
versions of f77...

At some point following the fix to shorten offsets to local data, a
buglet crept into the compiler which can cause a severe speed penalty
for f77 programs.  This bug probably affects the vast majority of
programs and it's rather important that it be repaired if you want to
see any sort of performance from your f77 software.

The problem is that data is sometimes only aligned to 16-bit boundaries
instead of 32-bit boundaries.  The VAX can fetch data from any
alignment, but it is considerably more efficient to fetch 32-bit or
larger data which is aligned to 32 bits.  The program that led me to
find this bug runs more than twice as fast when the bug is fixed...

The fix is to make the code for the function putstr() in f77pass1/put.c
agree with the comment that heads it.  Here is a revised putstr():

------------------------------------------------------------------------
/*
 * put out a character string constant.  begin every one on
 * a long integer boundary, and pad with nulls
 */
putstr(fp, s, n)
FILEP fp;
register char *s;
register int n;
{
int b[SZLONG];
register int i;

i = 0;
while(--n >= 0)
        {
        b[i++] = *s++;
        if(i == SZLONG)
                {
                prchars(fp, b);
                prchars(fp, b+SZSHORT);
                i = 0;
                }
        }

while(i < SZLONG)
        b[i++] = '\0';
prchars(fp, b);
prchars(fp, b+SZSHORT);
}
------------------------------------------------------------------------

Donn Seeley    University of Utah CS Dept    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn