[gnu.gcc.bug] Loop optimization in GCC 1.28

cooper@UUNET.UU.NET (Clark Cooper) (09/30/88)

Symptom:
	GCC 1.28 with -O seems to be missing an obvious loop optimization.

Configurtion:
	md -> m68k.md
	tm.h -> tm-sun3.h
	aux-output.c -> output-m68k.c

Test File:
===========================
static char syn_tab[256];

static void
test ()
{
   register int c;

   for (c = 'a'; c <= 'z'; c++)
     syn_tab[c] = 1;
}
===========================

Compilation script:
===========================
gecrux% gcc -v -g -O -S junk.c
gcc version 1.28
 /usr/sculptorq/gnu/src/gcc/cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_FPU__-Dmc68020 junk.c /tmp/cca08120.cpp
GNU CPP version 1.28
 /usr/sculptorq/gnu/src/gcc/cc1 /tmp/cca08120.cpp -quiet -dumpbase junk.c -g -O -version -o junk.s
GNU C version 1.28 (68k, MIT syntax) compiled by CC.
===========================

Portion of .s file:
===========================
...
_test:
	.stabd 68,0,5
	link a6,#0
LBB2:
	.stabd 68,0,8
	moveq #97,d0
	lea _syn_tab,a0		<--
L5:				  |
	.stabd 68,0,9		  |
	moveb #1,a0@(d0:l)	  |
	.stabd 68,0,8		  |
	addql #1,d0		  |
	moveq #122,d1		--  Why isn't this outside the loop ?
	cmpl d0,d1
	jge L5
LBE2:
...
===========================
Clark Cooper       cooper@gecrux.steinmetz.ge.com, coopercc@crd.ge.com,
                   coopercc@ge-crd.arpa, ...!uunet!steinmetz!cooper