[PATCH] D140454: [RISCV] Optimize (select (x in [0, 1] != 0), y, (z ^ y) ) -> ((x-1) & z ) ^ y

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 22:07:52 PST 2022


craig.topper created this revision.
craig.topper added reviewers: reames, asb, luismarques.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, 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.

This is the inverted case of
(select (x in [0,1] == 0), y, (z ^ y) ) -> (-x & z ) ^ y

Instead of -x we need -(x ^ 1) which simplifies to -(1-x) or (x-1).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140454

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140454.484464.patch
Type: text/x-patch
Size: 24799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221221/4e84cd91/attachment.bin>


More information about the llvm-commits mailing list