[PATCH] D129888: [RISCV] Teach RISCVCodeGenPrepare to optimize (i64 (and (zext/sext (i32 X), C1)))

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 11:14:40 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: reames, asb, luismarques, frasercrmck.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

If X is known positive by a dominating condition, we can fill in
ones into the upper bits of C1 <https://reviews.llvm.org/C1> if that would allow it to become an
simm12 allowing the use of ANDI.

This pattern often occurs in unrolled loops where the induction
variable has been widened.

To get the best benefit from this, I had to move the pass above
ConstantHoisting which is in addIRPasses. Otherwise the AND constant
is often hoisted away from the AND.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129888

Files:
  llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/test/CodeGen/RISCV/O3-pipeline.ll
  llvm/test/CodeGen/RISCV/riscv-codegenprepare-asm.ll
  llvm/test/CodeGen/RISCV/riscv-codegenprepare.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129888.445070.patch
Type: text/x-patch
Size: 14586 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220715/46cdc1a6/attachment.bin>


More information about the llvm-commits mailing list