[gnu.gcc.bug] bug in 1.32 optimizer

pickert@UICSRD.CSRD.UIUC.EDU (Joseph R. Pickert) (01/11/89)

BUG IN GCC 1.32 Optimizer.

The following subroutine produces bad code (see keywords RIGHT and WRONG
below) with the gcc 1.32 optimizer turned on.

build_sig(x, sig)
char *x;
int sig;
{
  register struct frame {
	short	f_sig;
  } *fp;
  fp = (struct frame *) x;
  fp->f_sig = sig;
}

NOT OPTIMIZED:
================================================================================

gcc version 1.32
 /usr/src/local/gnuC++/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 c.c /tmp/cca28852.cpp
GNU CPP version 1.32
 /usr/src/local/gnuC++/lib/gcc-cc1 /tmp/cca28852.cpp -quiet -dumpbase c.c -version -o c.s
GNU C version 1.32 (68k, MIT syntax) compiled by GNU C version 1.32.

yields:

#NO_APP
gcc_compiled.:
.text
	.even
.globl _build_sig
_build_sig:
	link a6,#0
	movel a6@(8),a0
	movew a6@(14),a0@		<============ RIGHT
L1:
	unlk a6
	rts


OPTIMIZED:
================================================================================

gcc version 1.32
 /usr/src/local/gnuC++/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 c.c /tmp/cca28866.cpp
GNU CPP version 1.32
 /usr/src/local/gnuC++/lib/gcc-cc1 /tmp/cca28866.cpp -quiet -dumpbase c.c -O -version -o c.s
GNU C version 1.32 (68k, MIT syntax) compiled by GNU C version 1.32.

yields:

#NO_APP
gcc_compiled.:
.text
	.even
.globl _build_sig
_build_sig:
	link a6,#0
	movel a6@(8),a0
	movew a6@(12),a0@		<============ WRONG, sb a6@(14)
	unlk a6
	rts