[gnu.gcc.bug] constant propagation could be better

shep@ALLSPICE.LCS.MIT.EDU (01/26/89)

allspice<15>% cat bar.c
int bar()
{
  int i = 40;
  if (i > 100) panic();
#ifdef FOO
  if (i > 100) panic();
#endif
  return i;
}
allspice<16>% gcc -v -O -S bar.c
gcc version 1.32
 /u/shep/gcc-1.32/cpp -v -undef -D__GNUC__ -Dvax -Dunix -D__vax__ -D__unix__ -D__OPTIMIZE__ bar.c /tmp/cc003059.cpp
GNU CPP version 1.32
 /u/shep/gcc-1.32/cc1 /tmp/cc003059.cpp -quiet -dumpbase bar.c -O -version -o bar.s
GNU C version 1.32 (vax) compiled by GNU C version 1.32.
allspice<17>% cat bar.s
#NO_APP
gcc_compiled.:
.text
        .align 1
.globl _bar
_bar:
        .word 0x0
        movl $40,r0
        ret
allspice<18>% gcc -DFOO -v -O -S bar.c
gcc version 1.32
 /u/shep/gcc-1.32/cpp -v -DFOO -undef -D__GNUC__ -Dvax -Dunix -D__vax__ -D__unix__ -D__OPTIMIZE__ bar.c /tmp/cc003066.cpp
GNU CPP version 1.32
 /u/shep/gcc-1.32/cc1 /tmp/cc003066.cpp -quiet -dumpbase bar.c -O -version -o bar.s
GNU C version 1.32 (vax) compiled by GNU C version 1.32.
allspice<19>% cat bar.s
#NO_APP
gcc_compiled.:
.text
        .align 1
.globl _bar
_bar:
        .word 0x40
        movl $40,r6
        cmpl r6,$100
        jleq L2
        calls $0,_panic
L2:
        movl r6,r0
        ret
allspice<20>% 


I'm nit picking here...  Constant propagation could be better.  Notice
that when FOO is defined, it still generates the test for (i > 100)
and a call to panic().

				-Tim Shepard
				<shep@ptt.lcs.mit.edu>