GCC Bugzilla – Bug 31152
-(x>y) generates wrong code
Last modified: 2007-06-23 19:07:49 UTC
The actual gcc version is
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
When compiled and run with this gcc version, using the command line
gcc -O xxx.c && a.out
the attached program outputs -1, whereas the correct output is 0. If
I use gcc 3.3.6 or leave away the -O flag, the program produces
Subject: Re: New: -(x>y) generates wrong code
I cannot create an attachment in Bugzilla, so I'll just append the
test program here:
long foo(long x, long y);
long foo(long x, long y)
It works for me on x86_64 and i686 with 4.0.0, 4.1.0 and 4.1.2. So this looks like a target issue.
I can reproduce the problem on a Linkstation Pro with an ARM926EJ CPU. I compiled GCC SVN revision 123155 from the gcc-4_2-branch on it. Creating wrong assembler code is at least a major bug, even when using the optimizing switch (which many programs do), so please change severity to "major".
Confirmed. This is a bug in the negscc pattern in arm.md. It's only been there since 1994!
Subject: Bug 31152
Date: Sat Jun 23 18:07:04 2007
New Revision: 125973
* arm.md (negscc): Match the correct operand for optimized LT0 test.
Remove optimization for GT.
Fixed on trunk.
Are you not going to apply this to 4.1 and 4.2?
Richard, I think this patch should also be added to the 4.1 and 4.2 branches.