[llvm] 1ef1eec - [GlobalISel][NFC] Use GenericMachineInstrs in CombinerHelper::reassociationCanBreakAddressingModePattern().
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 3 21:29:22 PDT 2023
Author: Amara Emerson
Date: 2023-09-03T21:17:31-07:00
New Revision: 1ef1eec8db21f35286d9c7fa0a48bb0b6446fe11
URL: https://github.com/llvm/llvm-project/commit/1ef1eec8db21f35286d9c7fa0a48bb0b6446fe11
DIFF: https://github.com/llvm/llvm-project/commit/1ef1eec8db21f35286d9c7fa0a48bb0b6446fe11.diff
LOG: [GlobalISel][NFC] Use GenericMachineInstrs in CombinerHelper::reassociationCanBreakAddressingModePattern().
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index f5ca614e568ef5..6c2b7dd03a8947 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -4262,20 +4262,20 @@ bool CombinerHelper::matchBitfieldExtractFromShrAnd(
}
bool CombinerHelper::reassociationCanBreakAddressingModePattern(
- MachineInstr &PtrAdd) {
- assert(PtrAdd.getOpcode() == TargetOpcode::G_PTR_ADD);
+ MachineInstr &MI) {
+ auto &PtrAdd = cast<GPtrAdd>(MI);
- Register Src1Reg = PtrAdd.getOperand(1).getReg();
- MachineInstr *Src1Def = getOpcodeDef(TargetOpcode::G_PTR_ADD, Src1Reg, MRI);
+ Register Src1Reg = PtrAdd.getBaseReg();
+ auto *Src1Def = getOpcodeDef<GPtrAdd>(Src1Reg, MRI);
if (!Src1Def)
return false;
- Register Src2Reg = PtrAdd.getOperand(2).getReg();
+ Register Src2Reg = PtrAdd.getOffsetReg();
if (MRI.hasOneNonDBGUse(Src1Reg))
return false;
- auto C1 = getIConstantVRegVal(Src1Def->getOperand(2).getReg(), MRI);
+ auto C1 = getIConstantVRegVal(Src1Def->getOffsetReg(), MRI);
if (!C1)
return false;
auto C2 = getIConstantVRegVal(Src2Reg, MRI);
@@ -4299,9 +4299,8 @@ bool CombinerHelper::reassociationCanBreakAddressingModePattern(
ConvUseMI = &*MRI.use_instr_nodbg_begin(DefReg);
ConvUseOpc = ConvUseMI->getOpcode();
}
- auto LoadStore = ConvUseOpc == TargetOpcode::G_LOAD ||
- ConvUseOpc == TargetOpcode::G_STORE;
- if (!LoadStore)
+ auto *LdStMI = dyn_cast<GLoadStore>(ConvUseMI);
+ if (!LdStMI)
continue;
// Is x[offset2] already not a legal addressing mode? If so then
// reassociating the constants breaks nothing (we test offset2 because
@@ -4309,11 +4308,9 @@ bool CombinerHelper::reassociationCanBreakAddressingModePattern(
TargetLoweringBase::AddrMode AM;
AM.HasBaseReg = true;
AM.BaseOffs = C2APIntVal.getSExtValue();
- unsigned AS =
- MRI.getType(ConvUseMI->getOperand(1).getReg()).getAddressSpace();
- Type *AccessTy =
- getTypeForLLT(MRI.getType(ConvUseMI->getOperand(0).getReg()),
- PtrAdd.getMF()->getFunction().getContext());
+ unsigned AS = MRI.getType(LdStMI->getPointerReg()).getAddressSpace();
+ Type *AccessTy = getTypeForLLT(LdStMI->getMMO().getMemoryType(),
+ PtrAdd.getMF()->getFunction().getContext());
const auto &TLI = *PtrAdd.getMF()->getSubtarget().getTargetLowering();
if (!TLI.isLegalAddressingMode(PtrAdd.getMF()->getDataLayout(), AM,
AccessTy, AS))
More information about the llvm-commits
mailing list