gcc 2.7.2.1 optimizer bug?

Josef Wolf jw@raven.inka.de
Thu Mar 12 13:00:00 GMT 1998


Hello!

It looks like I've been hit by an optimizer-bug in the cross-gcc-2.7.2.1
for embedded m68k. It was built with the patches from cygnus. I know,
this is an outdated version. I just want to mention it for the case
it is an unknown bug and it still exists in the newest version.
Does anybody know if this is an known bug and if is still exists
in 2.8.* ?

The bug seems to be triggered with -fforce-mem (and therefore
with -O2 too)

Here it goes (note the lines with '!!!!!!!!!!!'):

$ cat t.c
static unsigned long *bar = 0; /* should be ptr to 32 bit on m68k */

void foo (void)
{
  if (bar && *bar) (*bar)--;
}
$ m68k-coff-gcc -v
Reading specs from /usr/local/m68k-emb/lib/gcc-lib/m68k-coff/2.7.2.1/specs
gcc version 2.7.2.1
$ m68k-coff-gcc -S -O1 -ansi -m68332 -fomit-frame-pointer -fforce-mem t.c
$ cat t.s
	.file	"t.c"
gcc2_compiled.:
__gnu_compiled_c:
.data
	.even
bar:
	.long 0
.text
	.even
.globl foo
foo:
	move.l bar,%a0
	tst.l %a0
	jbeq .L2
	move.l (%a0),%a1
	tst.l %a1
	jbeq .L2
	subq.w #1,%a1
	/*   ^ note the size spezifier here 16 bit !!!!!!!!!!!!!! */
	move.l %a1,(%a0)
.L2:
	rts
	nop
$ m68k-coff-gcc -S -O1 -ansi -m68332 -fomit-frame-pointer t.c
$ cat t.s
	.file	"t.c"
gcc2_compiled.:
__gnu_compiled_c:
.data
	.even
bar:
	.long 0
.text
	.even
.globl foo
foo:
	tst.l bar
	jbeq .L2
	move.l bar,%a0
	tst.l (%a0)
	jbeq .L2
	subq.l #1,(%a0)
	/*   ^ note the size spezifier here 32 bit !!!!!!!!!!!!!! */
.L2:
	rts
	nop



More information about the crossgcc mailing list