[Bug rtl-optimization/60554] redundant instruction is generated for setting the flags on x86

l_belev at yahoo dot com gcc-bugzilla@gcc.gnu.org
Mon Mar 17 16:50:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60554

--- Comment #1 from Luchezar Belev <l_belev at yahoo dot com> ---
since all (x^0x80000000), (x+0x80000000) and (x-0x80000000) are equivalend in
this case, if GCC had used the subtraction (instead of the addition) it could
optimize the code even further by considering the fact that intermediate result
is not needed and use cmpl instead of subl:

_is_float_negative:
   cmpl $0x80000000, 4(%esp)
   setg %al
   movzbl %al, %eax
   ret

which is the same as if the function was written as
 int is_float_negative(int x) { return (unsigned)x > 0x80000000; }



More information about the Gcc-bugs mailing list