This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/37784] New: inefficient code for double compare double yielding double
- From: "rrh at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Oct 2008 18:08:50 -0000
- Subject: [Bug rtl-optimization/37784] New: inefficient code for double compare double yielding double
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The function:
double dfunc_001 ( const double a, const double b) { return a > b; }
yields the x86_64 code:
cmpltsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd .LC1(%rip), %xmm1
andpd %xmm0, %xmm1
xorpd %xmm2, %xmm2
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
ret
.LC1:
.long 0
.long 1072693248
Where LC1 is the fp constant +1.0
The 3 instruction sequence preceding the ret (eg xorpd;andnpd;orpd) is not
needed. The xorpd generates a 0, which is anded with something to yield a 0,
which is or'ed in with the value (+0.0 or +1.0) to yield the result.
Similar illness is seen for the other compares built around cmpsd variants.
Some improvement is seen when compiling -O3, but in that case there are 2
unneeded instructions.
--
Summary: inefficient code for double compare double yielding
double
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rrh at google dot com
GCC build triplet: i686-host_pc-linux-gnu
GCC host triplet: i686-host_pc-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37784