[llvm] [RISCV] Combine (addi (addi)) and add post riscv-opt-w-instrs machine-combiner (PR #171165)

Piotr Fusik via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 12:58:38 PST 2025


================
@@ -2819,6 +2838,27 @@ genShXAddAddShift(MachineInstr &Root, unsigned AddOpIdx,
   DelInstrs.push_back(&Root);
 }
 
+// Fold (addi (addi X, C1), C2) -> (addi X, C1+C2)
+static void combineADDIADDI(MachineInstr &Root,
+                            SmallVectorImpl<MachineInstr *> &InsInstrs,
+                            SmallVectorImpl<MachineInstr *> &DelInstrs) {
+  MachineFunction *MF = Root.getMF();
+  MachineRegisterInfo &MRI = MF->getRegInfo();
+  const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
----------------
pfusik wrote:

I copied this from https://github.com/llvm/llvm-project/pull/171165/files#diff-dc083bdfb8b95291a8e5e635119a632c192995b3d371ee671c4d507dddc29accL2770
Do you mean I could simply pass `this` ?

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


More information about the llvm-commits mailing list