[PATCH] D124222: [RISCV] Improve constant materialization for cases that can use LUI+ADDI instead of LUI+ADDIW.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 18:11:50 PDT 2022


craig.topper created this revision.
craig.topper added reviewers: luismarques, jrtc27, asb, frasercrmck.
Herald added subscribers: sunshaoce, VincentWu, luke957, 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, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

It's possible that we have a constant that isn't simm32 so we can't
use LUI+ADDIW, but we can use LUI+ADDI. Because ADDI uses a sign
extended constant, it's possible that after subtracting it out, we
end up with a simm32 that maps to LUI.

This patch detects this case after removing Lo12 and before shifting
the value for SLLI.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124222

Files:
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp
  llvm/test/CodeGen/RISCV/imm.ll
  llvm/test/CodeGen/RISCV/rv64zbs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124222.424349.patch
Type: text/x-patch
Size: 5596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220422/c44476ce/attachment.bin>


More information about the llvm-commits mailing list