[PATCH] D121664: [LegalizeTypes] Expand ABS in PromoteIntRes_ABS if it will expand to sra+xor+sub later.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 21:27:27 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: asb, spatel, RKSimon, efriedma.
Herald added subscribers: luke957, StephenFan, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, jgravelle-google, sbc100, dschuff.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay, aheejin.
Herald added a project: LLVM.

If we promote the ABS and then Expand in LegalizeDAG, then both the
sra and the xor will have their inputs sign extended. This generates
extra code on RISCV which lacks an i8 or i16 sign extend instructon.
If we expand during type legalization, then only the sra will get its
input sign extended. RISCV is able to combine this with the sra by
doing a shift left followed by an sra.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121664

Files:
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/test/CodeGen/RISCV/iabs.ll
  llvm/test/CodeGen/WebAssembly/PR41149.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121664.415314.patch
Type: text/x-patch
Size: 8754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220315/bfba73dd/attachment.bin>


More information about the llvm-commits mailing list