[PATCH] D147538: [RISCV] Add DAG combine to fold (add (setcc x, 0, setlt), -1) -> (sra x, xlen - 1)

Liao Chunyu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 08:20:46 PDT 2023


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

  The result of add/sub + setcc is 0 or 1 for all bits.
  The sra instruction get the same result.
  
  fold (add (setcc x, 0, setlt), -1) -> (sra x, xlen - 1)
  fold (add (setcc 0, x, setgt), -1) -> (sra x, xlen - 1)
  fold (sub 0, (setcc x, 0, setlt)) -> (sra x , xlen - 1)
  fold (sub 0, (setcc 0, x, setgt)) -> (sra x , xlen - 1)
  
  These testcases do not contain setgt, I can not find a testcase now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147538

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/alu64.ll
  llvm/test/CodeGen/RISCV/bittest.ll
  llvm/test/CodeGen/RISCV/double-convert.ll
  llvm/test/CodeGen/RISCV/float-convert.ll
  llvm/test/CodeGen/RISCV/fpclamptosat.ll
  llvm/test/CodeGen/RISCV/fpclamptosat_vec.ll
  llvm/test/CodeGen/RISCV/half-convert.ll
  llvm/test/CodeGen/RISCV/rotl-rotr.ll
  llvm/test/CodeGen/RISCV/selectcc-to-shiftand.ll
  llvm/test/CodeGen/RISCV/shift-amount-mod.ll
  llvm/test/CodeGen/RISCV/shift-masked-shamt.ll
  llvm/test/CodeGen/RISCV/shifts.ll
  llvm/test/CodeGen/RISCV/wide-scalar-shift-by-byte-multiple-legalization.ll
  llvm/test/CodeGen/RISCV/wide-scalar-shift-legalization.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147538.510812.patch
Type: text/x-patch
Size: 90066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230404/63570eac/attachment.bin>


More information about the llvm-commits mailing list