[PATCH] D105918: [SelectionDAG][RISCV] Use isSExtCheaperThanZExt to control whether sext or zext is used for constant folding any_extend.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 13 10:52:30 PDT 2021


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

RISCV would prefer a sign extended constant since that works better
with our constant materialization. We have an existing TLI hook we
use to control sign extension of setcc operands in type legalization.
That hook happens to do the right check we need here, but might be
straying from its original purpose. With only RISCV defining this
hook in tree, I wasn't sure if it was worth adding another hook
with identical behavior.

This is an alternative to D105785 <https://reviews.llvm.org/D105785> where I tried to handle this in
the RISCV backend by not creating ANY_EXTENDs in some places.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105918

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/alu32.ll
  llvm/test/CodeGen/RISCV/rv64zbb-zbp.ll
  llvm/test/CodeGen/RISCV/xaluo.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105918.358348.patch
Type: text/x-patch
Size: 10870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210713/f75160f8/attachment.bin>


More information about the llvm-commits mailing list