[llvm] [AArch64][GlobalISel] Reassociate add sub mul. (PR #180753)
Ryan Cowan via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 01:46:06 PST 2026
================
@@ -554,6 +554,40 @@ void applyExtMulToMULL(MachineInstr &MI, MachineRegisterInfo &MRI,
MI.eraseFromParent();
}
+static bool matchSubAddMulReassoc(Register Mul1, Register Mul2, Register Sub,
+ Register Src, MachineRegisterInfo &MRI) {
+ if (!MRI.hasOneUse(Sub))
+ return false;
+ if (getIConstantVRegValWithLookThrough(Src, MRI))
+ return false;
+ MachineInstr *M1 = getDefIgnoringCopies(Mul1, MRI);
+ if (M1->getOpcode() != AArch64::G_MUL &&
+ M1->getOpcode() != AArch64::G_SMULL &&
+ M1->getOpcode() != AArch64::G_UMULL)
+ return false;
+ MachineInstr *M2 = getDefIgnoringCopies(Mul2, MRI);
+ if (M2->getOpcode() != AArch64::G_MUL &&
+ M2->getOpcode() != AArch64::G_SMULL &&
+ M2->getOpcode() != AArch64::G_UMULL)
+ return false;
+ return true;
+}
+
+static void applySubAddMulReassoc(MachineInstr &MI, MachineInstr &Sub,
----------------
HolyMolyCowMan wrote:
Would it be useful to make it obvious this is reverting a middle end transform in the name?
https://github.com/llvm/llvm-project/pull/180753
More information about the llvm-commits
mailing list