Thumb1 has very limited immediate modes, so turning an "and" into a shift can save multiple instructions.
It's possible to simplify the generated code for test2 and test3 in cmp-and-fold.ll a little more, but I'll implement that as a followup.
Paths
| Differential D65175
[ARM] Transform compare of masked value to shift on Thumb1. ClosedPublic Authored by efriedma on Jul 23 2019, 5:06 PM.
Details Summary Thumb1 has very limited immediate modes, so turning an "and" into a shift can save multiple instructions. It's possible to simplify the generated code for test2 and test3 in cmp-and-fold.ll a little more, but I'll implement that as a followup.
Diff Detail
Event Timeline
Comment Actions Any reason why not to use this for thumb2 as well? It looks like it would be useful for T2 codesize. Comment Actions
You can't save any instructions this way on Thumb2; every AND which can be transformed is a legal and/bic/bfc. I guess a narrow lsls+cmp is still two bytes shorter than bic+cmp.
efriedma added a child revision: D65351: [ARM] Lower "(x<<c) > 0x80000000U" to "lsls" on Thumb1..Jul 26 2019, 2:48 PM This revision is now accepted and ready to land.Jul 31 2019, 2:59 AM Closed by commit rL367491: [ARM] Transform compare of masked value to shift on Thumb1. (authored by efriedma). · Explain WhyJul 31 2019, 4:19 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 212699 llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/test/CodeGen/Thumb/cmp-and-fold.ll
|