[Bug target/54829] bad optimization: sub followed by cmp w/ zero (x86 & ARM)

daniel.santos at pobox dot com gcc-bugzilla@gcc.gnu.org
Thu Aug 11 21:49:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54829

Daniel Santos <daniel.santos at pobox dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #10 from Daniel Santos <daniel.santos at pobox dot com> ---
(In reply to Richard Earnshaw from comment #8)
> Unfortunately, computers don't to infinite precision arithmetic by default. 
> That would perform a different comparison in that it checks that r0 > r1,
> not whether r0 - r1 > 0.  The difference, for signed comparisons, is when
> overflow occurs.

Looks like I've forgotten to close this bug after retesting. Thank you again
Richard for clarifying this. When modifying the compare function as described
above, optimization is perfect on all targets I've tested (x86, ARM and MIPS).


More information about the Gcc-bugs mailing list