[llvm] 058d521 - [RISCV] Avoid repeated code in SelectAddrRegImm. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 30 17:22:25 PDT 2022
Author: Craig Topper
Date: 2022-06-30T17:22:04-07:00
New Revision: 058d521ea4455a71b22ebdbbadcce473c132567b
URL: https://github.com/llvm/llvm-project/commit/058d521ea4455a71b22ebdbbadcce473c132567b
DIFF: https://github.com/llvm/llvm-project/commit/058d521ea4455a71b22ebdbbadcce473c132567b.diff
LOG: [RISCV] Avoid repeated code in SelectAddrRegImm. NFC
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
index ba146f883b39..96d2bf572765 100644
--- a/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -1871,15 +1871,16 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
if (SelectAddrFrameIndex(Addr, Base, Offset))
return true;
+ SDLoc DL(Addr);
+ MVT VT = Addr.getSimpleValueType();
+
if (CurDAG->isBaseWithConstantOffset(Addr)) {
int64_t CVal = cast<ConstantSDNode>(Addr.getOperand(1))->getSExtValue();
if (isInt<12>(CVal)) {
Base = Addr.getOperand(0);
if (auto *FIN = dyn_cast<FrameIndexSDNode>(Base))
- Base = CurDAG->getTargetFrameIndex(FIN->getIndex(),
- Subtarget->getXLenVT());
- Offset = CurDAG->getTargetConstant(CVal, SDLoc(Addr),
- Subtarget->getXLenVT());
+ Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), VT);
+ Offset = CurDAG->getTargetConstant(CVal, DL, VT);
return true;
}
}
@@ -1893,8 +1894,6 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
// We can use an ADDI for part of the offset and fold the rest into the
// load/store. This mirrors the AddiPair PatFrag in RISCVInstrInfo.td.
int64_t Adj = CVal < 0 ? -2048 : 2047;
- SDLoc DL(Addr);
- MVT VT = Addr.getSimpleValueType();
Base = SDValue(
CurDAG->getMachineNode(RISCV::ADDI, DL, VT, Addr.getOperand(0),
CurDAG->getTargetConstant(Adj, DL, VT)),
@@ -1905,7 +1904,7 @@ bool RISCVDAGToDAGISel::SelectAddrRegImm(SDValue Addr, SDValue &Base,
}
Base = Addr;
- Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), Subtarget->getXLenVT());
+ Offset = CurDAG->getTargetConstant(0, DL, VT);
return true;
}
More information about the llvm-commits
mailing list