This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] When matching a disguised rotate by constant don't forget to apply LHSMask/RHSMask.
ClosedPublic

Authored by craig.topper on Apr 29 2022, 11:21 PM.

Details

Summary

We try to match as a disguised rotate by constant of these forms
(shl (X | Y), C1) | (srl X, C2) --> (rotl X, C1) | (shl Y, C1)
(shl X, C1) | (srl (X | Y), C2) --> (rotl X, C1) | (srl Y, C2)

We may have also looked through an AND to find the shift. If we
did, we need to apply a mask to the result.

I'll add an AArch64 test and pre-commit it and the RISC-V test
tomorrow.

Fixes PR55201.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 29 2022, 11:21 PM
craig.topper requested review of this revision.Apr 29 2022, 11:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2022, 11:21 PM
RKSimon accepted this revision.Apr 30 2022, 1:42 AM

LGTM (please pre-commit the test so the patch shows the codegen fix diff)

This revision is now accepted and ready to land.Apr 30 2022, 1:42 AM

Add AArch64 test