Previously it only avoided optimizing signed comparisons to 0.
Sometimes the DAGCombiner will optimize the unsigned comparisons
to 0 before it gets to the peephole pass, but sometimes it doesn't.
Fix for PR22373.
Paths
| Differential D7274
Fix ARM peephole optimizeCompare to avoid optimizing unsigned cmp to 0. ClosedPublic Authored by jvoung on Jan 29 2015, 3:17 PM.
Details Summary Previously it only avoided optimizing signed comparisons to 0. Fix for PR22373.
Diff Detail Event TimelineComment Actions lgtm otherwise.
jvoung edited edge metadata. Comment ActionsApply JF's review suggestion -- annotate the switch cases w/ the bits used. This revision is now accepted and ready to land.Jan 31 2015, 9:23 PM Closed by commit rL227809: Fix ARM peephole optimizeCompare to avoid optimizing unsigned cmp to 0. (authored by jvoung). · Explain WhyFeb 2 2015, 8:58 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 18998 lib/Target/ARM/ARMBaseInstrInfo.cpp
test/CodeGen/ARM/sub-cmp-peephole.ll
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I think it would be better to rewire the code as:
switch (CC) { case ARMCC::EQ: // Z case ARMCC::NE: // Z case ARMCC::MI: // N case ARMCC::PL: // N case ARMCC::AL: // none // CPSR can be used multiple times, we should continue. break; case ARMCC::CS: // C case ARMCC::CC: // C case ARMCC::VS: // V case ARMCC::VC: // V case ARMCC::HI: // C Z case ARMCC::LS: // C Z case ARMCC::GE: // N V case ARMCC::LT: // N V case ARMCC::GT: // Z N V case ARMCC::LE: // Z N V // The instruction uses the V bit or C bit which is not safe. return false; }