This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Combine ands+lsls to lsls+lsrs for Thumb1.
ClosedPublic

Authored by efriedma on Dec 21 2018, 3:09 PM.

Details

Summary

This patch may seem familiar... but my previous patch handled the equivalent lsls+and, not this case. Usually instcombine puts the "and" after the shift, so this case doesn't come up. However, if the shift is generated by lowering a GEP, it won't get canonicalized by instcombine, and DAGCombine doesn't have an equivalent transform.

This also modifies isDesirableToCommuteWithShift to suppress DAGCombine transforms which would make the overall code worse after this transform.

I'm not really happy adding a bunch of code to handle this, but it would probably be tricky to substantially improve the behavior of the target-independent DAGCombine here.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma created this revision.Dec 21 2018, 3:09 PM

Sounds good to me. Just adding Sjoerd/Sam who might know more about this code.

lib/Target/ARM/ARMISelLowering.cpp
10424 ↗(On Diff #179369)

isThumb1Only implies isThumb already?

12460 ↗(On Diff #179369)

Formatting?

samparker added inline comments.Jan 15 2019, 1:56 AM
lib/Target/ARM/ARMISelLowering.cpp
10428 ↗(On Diff #179369)

This can be removed and the statement from line 10444 hoisted up.

12474 ↗(On Diff #179369)

I think we should avoid c-style casting.

efriedma updated this revision to Diff 181937.Jan 15 2019, 4:58 PM

Address review comments

dmgreen accepted this revision.Jan 16 2019, 4:05 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Jan 16 2019, 4:05 AM
This revision was automatically updated to reflect the committed changes.