[lld] [llvm] [RISCV] Teach RISCVMergeBaseOffset to merge %lo into load/store folding arithmetic (PR #185353)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 09:52:18 PDT 2026


================
@@ -709,6 +965,10 @@ bool RISCVMergeBaseOffsetOpt::runOnMachineFunction(MachineFunction &Fn) {
       MadeChange |= detectAndFoldOffset(Hi, *Lo);
       MadeChange |= foldIntoMemoryOps(Hi, *Lo);
       MadeChange |= foldShxaddIntoScaledMemory(Hi, *Lo);
+      // Non-constant addressing of global array subscripts, which can be
+      // increase the optimization scenarios of gp-relax
+      if (Hi.getOpcode() != RISCV::AUIPC && Hi.getOperand(1).isGlobal() && Lo)
----------------
topperc wrote:

Move this check into foldGPIntoMemoryOps to keep this code clean?

https://github.com/llvm/llvm-project/pull/185353


More information about the llvm-commits mailing list