[PATCH] D99021: [RISCV] Add a special case to lowerSELECT for select of 2 constants with a SETLT condition.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 20 10:17:26 PDT 2021


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

If the constants have a difference of 1 we can convert one to
the other by adding or subtracting the condition.

We have a DAG combine for this, but it only runs before type
legalization. If the select is introduced later during type
legalization or op legalization we will miss it.

We don't need a specific condition, but some conditions are
harder to materialize than others on RISCV. I know that SETLT
will be a single instruction and it is what is used by the
motivating pattern from signed saturating add/sub.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99021

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/sadd_sat.ll
  llvm/test/CodeGen/RISCV/sadd_sat_plus.ll
  llvm/test/CodeGen/RISCV/ssub_sat.ll
  llvm/test/CodeGen/RISCV/ssub_sat_plus.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99021.332116.patch
Type: text/x-patch
Size: 23638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210320/8f0e7bea/attachment.bin>


More information about the llvm-commits mailing list