http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60554
Bug ID: 60554 Summary: redundant instruction is generated for setting the flags on x86 Product: gcc Version: unknown Status: UNCONFIRMED Severity: minor Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: l_belev at yahoo dot com consider this simple function: int is_float_negative(int x) { return (int)(x ^ 0x80000000) > 0; } for x86, with options "-O3 -march=core2", GCC 4.8.2 generates the following code: .... _is_float_negative: movl 4(%esp), %eax addl $-2147483648, %eax testl %eax, %eax setg %al movzbl %al, %eax ret .... apparently (x^0x80000000) is replaced with (x+0x80000000), that's ok. the problem is the testl instruction - why the compiler decided to emit it? the addl instruction itself sets the needed flags (Z and N) just right.