[PATCH] D98877: [RISCV] Use selectImm for RV32. NFC
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 18 10:13:17 PDT 2021
craig.topper created this revision.
craig.topper added reviewers: asb, luismarques.
Herald added subscribers: StephenFan, vkmr, frasercrmck, evandro, 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, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.
Previously we used selectImm for RV64 and isel patterns for
RV32. This should be NFC, but will allow RV32 and RV64 to share
improvements in the future. For example, it might be useful to
use BSETI from Zbs to make single bit constants.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98877
Files:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.td
Index: llvm/lib/Target/RISCV/RISCVInstrInfo.td
===================================================================
--- llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -308,21 +308,6 @@
def AddrFI : ComplexPattern<iPTR, 1, "SelectAddrFI", [frameindex], []>;
def BaseAddr : ComplexPattern<iPTR, 1, "SelectBaseAddr">;
-// Extract least significant 12 bits from an immediate value and sign extend
-// them.
-def LO12Sext : SDNodeXForm<imm, [{
- return CurDAG->getTargetConstant(SignExtend64<12>(N->getZExtValue()),
- SDLoc(N), N->getValueType(0));
-}]>;
-
-// Extract the most significant 20 bits from an immediate value. Add 1 if bit
-// 11 is 1, to compensate for the low 12 bits in the matching immediate addi
-// or ld/st being negative.
-def HI20 : SDNodeXForm<imm, [{
- return CurDAG->getTargetConstant(((N->getZExtValue()+0x800) >> 12) & 0xfffff,
- SDLoc(N), N->getValueType(0));
-}]>;
-
// Return the negation of an immediate value.
def NegImm : SDNodeXForm<imm, [{
return CurDAG->getTargetConstant(-N->getSExtValue(), SDLoc(N),
@@ -874,13 +859,6 @@
return MatchSLLIUW(N);
}]>;
-/// Immediates
-
-def : Pat<(simm12:$imm), (ADDI X0, simm12:$imm)>;
-def : Pat<(simm32hi20:$imm), (LUI (HI20 imm:$imm))>;
-def : Pat<(i32 (simm32:$imm)), (ADDI (LUI (HI20 imm:$imm)), (LO12Sext imm:$imm))>,
- Requires<[IsRV32]>;
-
/// Simple arithmetic operations
def : PatGprGpr<add, ADD>;
Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -416,11 +416,8 @@
ReplaceNode(Node, New.getNode());
return;
}
- int64_t Imm = ConstNode->getSExtValue();
- if (XLenVT == MVT::i64) {
- ReplaceNode(Node, selectImm(CurDAG, DL, Imm, XLenVT));
- return;
- }
+ ReplaceNode(Node, selectImm(CurDAG, DL, ConstNode->getSExtValue(), XLenVT));
+ return;
break;
}
case ISD::FrameIndex: {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98877.331607.patch
Type: text/x-patch
Size: 2105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210318/da4b88d1/attachment.bin>
More information about the llvm-commits
mailing list