[PATCH] D146635: [LegalizeTypes][RISCV] Add a special case for (add X, -1) to ExpandIntRes_ADDSUB

Liao Chunyu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 08:56:10 PDT 2023


liaolucy created this revision.
liaolucy added reviewers: craig.topper, spatel.
Herald added subscribers: jobnoorman, luke, VincentWu, StephenFan, 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, asb, 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.

On targets without ADDCARRY or ADDE, we need to emit a separate
 SETCC to determine carry from the low half to the high half. 
 The high half is calculated by a series of ADDs.

Without this patch, we get:

  Hi = (add (add LHSHi,(setult Lo, LHSLo), -1)

Where as with the patch we get:

  Hi = (sub LHSHi, (seteq LHSLo, 0)) 
   

Similar to gcc: https://godbolt.org/z/Kb78r4zh6


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146635

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/test/CodeGen/RISCV/atomicrmw-uinc-udec-wrap.ll
  llvm/test/CodeGen/RISCV/overflow-intrinsics.ll
  llvm/test/CodeGen/RISCV/sext-zext-trunc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146635.507377.patch
Type: text/x-patch
Size: 5633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230322/31836f18/attachment.bin>


More information about the llvm-commits mailing list