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

rearnsha at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 13 16:05:00 GMT 2012


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

--- Comment #5 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2012-10-13 16:04:55 UTC ---
The result of the comparison is used in more than one instruction, so combine
cannot safely rework the branch instructions that follow to ensure that the
result of the subtract is used correctly.

In fact, on ARM there is no branch instruction that can be used for "> 0" as a
side effect of a subtract.  To get the desired effect the code would have to be
completely re-arranged to factor out the "< 0" (bmi) and then "== 0" (beq)
cases first.



More information about the Gcc-bugs mailing list