[gnu.gcc.bug] Not a bug report - optimization

pardo@JUNE.CS.WASHINGTON.EDU (09/29/89)

This is not a bug report.  This is a comment about one more place to
do optmizations.

Gcc 1.36 for a Vax using config.gcc.

The optimizer does not recognize some non-overlapping variable
lifetimes.

	int z;

	bork()
	{
	    {
		int i;

		i = z + 4;
		zork (&i);
	    }
	    {
		int j;
		j = z + 5;
		zork (&j);
	    }
	}

gcc -O -S -v foo.c
gcc version 1.36
 /uns/usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dvax -Dunix -D__vax__ -D__unix__ -D__OPTIMIZE__ foo.c /usr/tmp/cca05236.cpp
GNU CPP version 1.36
 /uns/usr/local/lib/gcc-cc1 /usr/tmp/cca05236.cpp -quiet -dumpbase foo.c -O -version -o foo.s
GNU C version 1.36 (vax) compiled by GNU C version 1.36.
default target switches: -munix


	#NO_APP
	gcc_compiled.:
	.text
		.align 1
	.globl _bork
	_bork:
		.word 0x40
		subl2 $8,sp		# only needed subl2 $4.
		addl3 _z,$4,-4(fp)
		subl3 $4,fp,-(sp)
		movab _zork,r6
		calls $1,(r6)
		addl3 _z,$5,-8(fp)
		subl3 $8,fp,-(sp)
		calls $1,(r6)
		ret
	.comm _z,4

The place where this optimization is important is when `i' and `j' are
replaced by arrays; the difference in stack size (and thus caching
performance) is observable.

	;-D on  ( Yes, GNU improves cache performance, too! )  Pardo