Article View: gnu.gcc.bug
Article #2196constant propagation could be better
From: shep
Date: Wed, 25 Jan 1989 18:06
Date: Wed, 25 Jan 1989 18:06
57 lines
1817 bytes
1817 bytes
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>
Technical Details
Message-ID:
<8901251806.AA03078@PTT.LCS.MIT.EDU>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!ALLSPICE.LCS.MIT.EDU!shepShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!mcdchg!rutgers!tut.cis.ohio-state.edu!ALLSPICE.LCS.MIT.EDU!shep From: shep@ALLSPICE.LCS.MIT.EDU Newsgroups: gnu.gcc.bug Subject: constant propagation could be better Message-ID: <8901251806.AA03078@PTT.LCS.MIT.EDU> Date: 25 Jan 89 18:06:13 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 57