Article View: gnu.gcc.bug
Article #2110gcc 1.31 with -O generates bad compare
From: Brad Parker
Date: Mon, 02 Jan 1989 01:54
Date: Mon, 02 Jan 1989 01:54
88 lines
1757 bytes
1757 bytes
gcc 1.31 on a Sun 3/60 using SunOS 4.0; cross compiling for 68000 target.
I've been having fairly good luck with "-O" and "-O -fcombine-regs
-finline-functions -fstrength-reduce" (going for it ;-) except for the
following bug.
It seems that the branch type not correct;
----
func1()
{
}
typedef unsigned long ulong;
main()
{
int high_addr = 0;
/* generates wrong branch with -O */
if ( (ulong)func1 > (ulong)0xfc0000 )
high_addr = 1;
printf("func1 = %lx, high_addr = %d\n", (ulong)func1, high_addr);
}
----
(gcc -c show.c)
#NO_APP
.text
.even
.globl _func1
_func1:
link a6,#0
L1:
unlk a6
rts
LC0:
.ascii "func1 = %lx, high_addr = %d\12\0"
.even
.globl _main
_main:
link a6,#-4
clrl a6@(-4)
movel #16515072,d1
cmpl #_func1,d1
jcc L3 <--- correct, but not optimal
moveq #1,d1
movel d1,a6@(-4)
L3:
movel a6@(-4),sp@-
pea _func1
pea LC0
jbsr _printf
L2:
unlk a6
rts
-----
(gcc -c -O show.c)
#NO_APP
.text
.even
.globl _func1
_func1:
link a6,#0
unlk a6
rts
LC0:
.ascii "func1 = %lx, high_addr = %d\12\0"
.even
.globl _main
_main:
link a6,#0
clrl d0
movel #_func1+-16515072,d1 <--- better,
jls L3 <--- but wrong branch type
moveq #1,d0
L3:
movel d0,sp@-
pea _func1
pea LC0
jbsr _printf
unlk a6
rts
----
-brad
Technical Details
Message-ID:
<8901020154.AA07897@cayman.Cayman.COM>Path:
arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!HARVARD.HARVARD.EDU!brad%caymanShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!uunet!tut.cis.ohio-state.edu!HARVARD.HARVARD.EDU!brad%cayman From: brad%cayman@HARVARD.HARVARD.EDU (Brad Parker) Newsgroups: gnu.gcc.bug Subject: gcc 1.31 with -O generates bad compare Message-ID: <8901020154.AA07897@cayman.Cayman.COM> Date: 2 Jan 89 01:54:46 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 88