[PATCH] D120636: [RISCV] Custom type legalize i32 ISD::ABS on RV64 without Zbb.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 27 14:34:44 PST 2022


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

Default type legalization will create sext_inreg+abs, but we may
not be able to remove the sext_inreg.

Instead this patch expands abs during type legalization to
Y = sraiw X, 31; subw(xor X, Y), Y) which doesn't require the input
to be sign extended.

This gives a big improvement for some neg-abs tests where the
abs is used more than the the neg. Previously the abs was expanded
a different way before and after type legalization. Now they are
expanded in a similar way enabling more CSE.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120636

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/neg-abs.ll
  llvm/test/CodeGen/RISCV/rv64zbb.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120636.411702.patch
Type: text/x-patch
Size: 4244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220227/5067a9f4/attachment.bin>


More information about the llvm-commits mailing list