This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
dead code elimination bug in egcs-2.90.08
- To: egcs-bugs at cygnus dot com
- Subject: dead code elimination bug in egcs-2.90.08
- From: Burkhard Steding <bst at helios dot de>
- Date: Tue, 23 Sep 1997 11:11:36 +0200
Hi,
here is a little example that does not get compiled right.
I discovered this problem on sparc, but it does not seem
to be specific to any architecture or operating system.
############################################################
int ts(int a)
{
if (a < 1000 && a > 2000)
return 1;
else
return 0;
}
int tu(unsigned int a)
{
if (a < 1000 && a > 2000)
return 1;
else
return 0;
}
############################################################
The unsigned comparison is compiled right (0 is returned),
but the signed case is wrong (1 is returned), see below.
############################################################
.file "t.c"
! GNU C version egcs-2.90.08 970917 (gcc2-970802 experimental) (sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.90.08 970917 (gcc2-970802 experimental).
! options passed: -O
! options enabled: -fdefer-pop -fomit-frame-pointer -fthread-jumps
! -fpeephole -ffunction-cse -finline -fkeep-static-consts
! -fpcc-struct-return -fdelayed-branch -fexceptions -fcommon -fverbose-asm
! -fgnu-linker -falias-check -fargument-alias -mepilogue -mapp-regs
gcc2_compiled.:
.section ".text"
.align 4
.global ts
.type ts,#function
.proc 04
ts:
.LLFB1:
!#PROLOGUE# 0
!#PROLOGUE# 1
retl
mov 1,%o0
.LLFE1:
.LLfe1:
.size ts,.LLfe1-ts
.align 4
.global tu
.type tu,#function
.proc 04
tu:
.LLFB2:
!#PROLOGUE# 0
!#PROLOGUE# 1
retl
mov 0,%o0
.LLFE2:
.LLfe2:
.size tu,.LLfe2-tu
.ident "GCC: (GNU) egcs-2.90.08 970917 (gcc2-970802 experimental)"
############################################################
When compiled without -O, the generated code is correct.
BTW, it would be nice if "egcc -O -Wall ..." produced a warning
in cases like this.
--
_________________________________
/\ \
\_| Burkhard Steding |
| HELIOS Software GmbH |
| Steinriede 3 |
| 30827 Garbsen |
| Germany |
| |
| Tel.: +49 5131 709336 |
| Fax.: +49 5131 709325 |
| e-mail: bst@helios.de |
| ____________________________|___
\_/_______________________________/