This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54829] bad optimization: sub followed by cmp w/ zero (x86 & ARM)
- From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 13 Oct 2012 16:04:55 +0000
- Subject: [Bug target/54829] bad optimization: sub followed by cmp w/ zero (x86 & ARM)
- Auto-submitted: auto-generated
- References: <bug-54829-4@http.gcc.gnu.org/bugzilla/>
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.