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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 23:21:29 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.
Herald added subscribers: luke957, StephenFan, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, kristof.beyls, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a project: LLVM.

We try to match as a disguised rotate by constant of these forms
(shl (X | Y), C1 <https://reviews.llvm.org/C1>) | (srl X, C2) --> (rotl X, C1 <https://reviews.llvm.org/C1>) | (shl Y, C1 <https://reviews.llvm.org/C1>)
(shl X, C1 <https://reviews.llvm.org/C1>) | (srl (X | Y), C2) --> (rotl X, C1 <https://reviews.llvm.org/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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124711

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/RISCV/pr55201.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124711.426210.patch
Type: text/x-patch
Size: 4235 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220430/b72c0e14/attachment.bin>


More information about the llvm-commits mailing list