[llvm] [SystemZ] Enable MachineCombiner for FP reassociation (PR #83546)
Ulrich Weigand via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 03:43:49 PDT 2024
================
@@ -610,6 +610,23 @@ void SystemZInstrInfo::insertSelect(MachineBasicBlock &MBB,
.addImm(CCValid).addImm(CCMask);
}
+MachineInstr *SystemZInstrInfo::optimizeLoadInstr(MachineInstr &MI,
+ const MachineRegisterInfo *MRI,
+ Register &FoldAsLoadDefReg,
+ MachineInstr *&DefMI) const {
+ // Check whether we can move the DefMI load, and that it only has one use.
+ DefMI = MRI->getVRegDef(FoldAsLoadDefReg);
+ assert(DefMI);
+ bool SawStore = false;
+ if (!DefMI->isSafeToMove(nullptr, SawStore) ||
+ !MRI->hasOneNonDBGUse(FoldAsLoadDefReg))
+ return nullptr;
+
+ int UseOpIdx = MI.findRegisterUseOperandIdx(FoldAsLoadDefReg);
+ assert(UseOpIdx != -1 && "Expected FoldAsLoadDefReg to be used by MI.");
+ return foldMemoryOperand(MI, {((unsigned) UseOpIdx)}, *DefMI);
----------------
uweigand wrote:
The X86 version clears FoldAsLoadDefReg if sucessful. Not sure why since common code doesn't appear to rely on that. But I think we should be consistent here.
https://github.com/llvm/llvm-project/pull/83546
More information about the llvm-commits
mailing list