This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/11457] New:
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Jul 2003 22:20:19 -0000
- Subject: [Bug optimization/11457] New:
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11457
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: user42 at zip dot com dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
When presented with tests like "n>=0" followed by "n==0", two i386
"test" instructions are generated, where one would suffice. This is
apparently a regression from some point, since for instance gcc 2.95.4
generates only one.
Environment:
System: Linux blah 2.2.15 #1 Tue Apr 25 17:13:48 EST 2000 i586 unknown unknown GNU/Linux
Architecture: i586
<machine, os, target, libraries (multiple lines)>
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i386-linux
How-To-Repeat:
A file foo.c containing
void
foo (int n)
{
if (n >= 0)
{
if (n == 0)
zero ();
else
non_negative ();
}
else
negative ();
}
compiled with
gcc -O2 -S foo.c
produces foo.s containing the sequence
testl %eax, %eax
js .L2
testl %eax, %eax
jne .L3
I think the second "testl" is unnecessary, and that the code would be
smaller and probably faster if it was omitted.
It seems this was done in the past, for instance a recent Debian
packaged gcc 2.95.4 does it,
testl %eax,%eax
jl .L3
jne .L4