Article View: gnu.gcc.bug
Article #328gcc 2.2.2: "unsigned preserving" rule of "-traditional" causes problem
From: Peter Magnusson
Date: Wed, 29 Jul 1992 23:10
Date: Wed, 29 Jul 1992 23:10
85 lines
2155 bytes
2155 bytes
Comparing an "int" with a 32-bit constant generates strange code when the
"traditional" flag is selected.
Gcc version 2.2.2 (running on SPARCstation ELC 4/25 SunOS 4.1.2).
The following bit of code:
int
main()
{
int a,b;
b = 0x80000000;
if (b >= 0x80000000)
a = 0;
else
a = 1;
}
Generates the following code with "gcc -S":
.text
.align 4
.global _main
.proc 04
_main:
!#PROLOGUE# 0
save %sp,-144,%sp
!#PROLOGUE# 1
call ___main,0
nop
sethi %hi(-2147483648),%o0
st %o0,[%fp-24]
ld [%fp-24],%o0
sethi %hi(2147483647),%o2
or %o2,%lo(2147483647),%o1
cmp %o0,%o1
bleu L2 <========
nop
st %g0,[%fp-20]
b,a L3
L2:
mov 1,%o0
st %o0,[%fp-20]
L3:
L1:
ret
restore
When compiled with "gcc -S -traditional", the code is:
.text
.align 4
.global _main
.proc 04
_main:
!#PROLOGUE# 0
save %sp,-144,%sp
!#PROLOGUE# 1
call ___main,0
nop
sethi %hi(-2147483648),%o0
st %o0,[%fp-24]
ld [%fp-24],%o0
sethi %hi(2147483647),%o2
or %o2,%lo(2147483647),%o1
cmp %o0,%o1
ble L2 <======= !!!!
nop
st %g0,[%fp-20]
b,a L3
L2:
mov 1,%o0
st %o0,[%fp-20]
L3:
L1:
ret
Notice the change. The constant is decremented but the comparison is such that
the expression evaluates to false!
Peter Magnusson
Swedish Institute of Computer Science
psm@sics.se
Technical Details
Message-ID:
<9207291910.AA16575@nut.sics.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!sics.se!psmShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!sics.se!psm From: psm@sics.se (Peter Magnusson) Subject: gcc 2.2.2: "unsigned preserving" rule of "-traditional" causes problem Message-ID: <9207291910.AA16575@nut.sics.se> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 29 Jul 1992 23:10:25 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 86