[PATCH] D135316: [RISCV] Fold selects with -1 in either arm

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 13:33:34 PDT 2022


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

We can lower these as an or with the negative of the condition value.  This appears to result in significantly less branch-y code on multiple common idioms (as seen in tests).

Reviewers - I'm assuming the result of a setcc is [0,1] in this patch.  This is correct right?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135316

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/double-convert.ll
  llvm/test/CodeGen/RISCV/double-round-conv-sat.ll
  llvm/test/CodeGen/RISCV/float-convert.ll
  llvm/test/CodeGen/RISCV/float-round-conv-sat.ll
  llvm/test/CodeGen/RISCV/fpclamptosat.ll
  llvm/test/CodeGen/RISCV/half-convert.ll
  llvm/test/CodeGen/RISCV/half-round-conv-sat.ll
  llvm/test/CodeGen/RISCV/min-max.ll
  llvm/test/CodeGen/RISCV/rv32zbb-zbkb.ll
  llvm/test/CodeGen/RISCV/rv64zbb.ll
  llvm/test/CodeGen/RISCV/uadd_sat.ll
  llvm/test/CodeGen/RISCV/uadd_sat_plus.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135316.465534.patch
Type: text/x-patch
Size: 168854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/49429024/attachment.bin>


More information about the llvm-commits mailing list