[PATCH] D152147: [RISCV] Fold binary op into select if profitable.

Mikhail Gudim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 05:45:03 PDT 2023


mgudim created this revision.
mgudim added a reviewer: craig.topper.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 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, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
mgudim requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

Consider the following pattern `binOp (select cond, x, c0), c1`.
Where `c0` and `c1` are constants.
We can transform it to `select cond, binOp(x, c1), binOp(c0, c1)`.

If `binOp(c0, c1)` ends up being `0` or `-1` we can turn the select into
a more profitable sequence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152147

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/fold-binop-into-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152147.528383.patch
Type: text/x-patch
Size: 4291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230605/3e71f31e/attachment.bin>


More information about the llvm-commits mailing list