[llvm] [RISCV] Merge ADDI with X0 into base offset (PR #78940)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 21 22:50:11 PST 2024
================
@@ -193,9 +193,17 @@ bool RISCVMergeBaseOffsetOpt::foldLargeOffset(MachineInstr &Hi,
if (AddiImmOp.getTargetFlags() != RISCVII::MO_None)
return false;
Register AddiReg = OffsetTail.getOperand(1).getReg();
- if (!AddiReg.isVirtual())
- return false;
int64_t OffLo = AddiImmOp.getImm();
+
+ // Handle rs1 of ADDI is X0.
+ if (AddiReg == RISCV::X0) {
+ LLVM_DEBUG(dbgs() << " Offset Instrs: " << OffsetTail);
+ int64_t Offset = OffLo;
----------------
topperc wrote:
Why do we need a new variable `Offset`?
https://github.com/llvm/llvm-project/pull/78940
More information about the llvm-commits
mailing list