This testcase: int test (double a) { return __builtin_signbit (a + 1.0); }
produces quite non-optimal code when compiled with '-O2' (-fomit-frame-pointer): test: subl $12, %esp ! xorl %eax, %eax ! movl $1072693248, %edx ! movl %eax, (%esp) ! movl %edx, 4(%esp) ! fldl (%esp) faddl 16(%esp) fstpl (%esp) ? movl 4(%esp), %edx addl $12, %esp ? movl %edx, %eax andl $-2147483648, %eax ret Instructions marked with (!) could be replaced with a fld1. Instructions marked with (?) could be replaced with a "movl 4(%esp), %eax". Perhaps fxam could be used in this case? Then the code would look something like: fldl 4(%esp) fxam fnstsw %ax fstp %st(0) andl 0x02, %eax ret -- Summary: non-optimal code with __builtin_signbit Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: uros at kss-loka dot si CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21508