[llvm] r352716 - GlobalISel: Use helper function for MMO splitting
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 30 17:49:58 PST 2019
Author: arsenm
Date: Wed Jan 30 17:49:58 2019
New Revision: 352716
URL: http://llvm.org/viewvc/llvm-project?rev=352716&view=rev
Log:
GlobalISel: Use helper function for MMO splitting
Also fix an alignment bug getMachineMemOperand. If the
tracked value is null, the offset isn't tracked so the
base alignment needs to be reduced.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/trunk/lib/CodeGen/MachineFunction.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp?rev=352716&r1=352715&r2=352716&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp Wed Jan 30 17:49:58 2019
@@ -568,20 +568,18 @@ LegalizerHelper::LegalizeResult Legalize
LLT OffsetTy = LLT::scalar(
MRI.getType(MI.getOperand(1).getReg()).getScalarSizeInBits());
+ MachineFunction &MF = MIRBuilder.getMF();
SmallVector<unsigned, 2> DstRegs;
for (int i = 0; i < NumParts; ++i) {
unsigned PartDstReg = MRI.createGenericVirtualRegister(NarrowTy);
unsigned SrcReg = 0;
- unsigned Adjustment = i * NarrowSize / 8;
- unsigned Alignment = MinAlign(MMO.getAlignment(), Adjustment);
+ unsigned Offset = i * NarrowSize / 8;
- MachineMemOperand *SplitMMO = MIRBuilder.getMF().getMachineMemOperand(
- MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
- NarrowSize / 8, Alignment, MMO.getAAInfo(), MMO.getRanges(),
- MMO.getSyncScopeID(), MMO.getOrdering(), MMO.getFailureOrdering());
+ MachineMemOperand *SplitMMO =
+ MF.getMachineMemOperand(&MMO, Offset, NarrowSize / 8);
MIRBuilder.materializeGEP(SrcReg, MI.getOperand(1).getReg(), OffsetTy,
- Adjustment);
+ Offset);
MIRBuilder.buildLoad(PartDstReg, SrcReg, *SplitMMO);
@@ -684,18 +682,16 @@ LegalizerHelper::LegalizeResult Legalize
SmallVector<unsigned, 2> SrcRegs;
extractParts(MI.getOperand(0).getReg(), NarrowTy, NumParts, SrcRegs);
+ MachineFunction &MF = MIRBuilder.getMF();
for (int i = 0; i < NumParts; ++i) {
unsigned DstReg = 0;
- unsigned Adjustment = i * NarrowSize / 8;
- unsigned Alignment = MinAlign(MMO.getAlignment(), Adjustment);
+ unsigned Offset = i * NarrowSize / 8;
- MachineMemOperand *SplitMMO = MIRBuilder.getMF().getMachineMemOperand(
- MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
- NarrowSize / 8, Alignment, MMO.getAAInfo(), MMO.getRanges(),
- MMO.getSyncScopeID(), MMO.getOrdering(), MMO.getFailureOrdering());
+ MachineMemOperand *SplitMMO =
+ MF.getMachineMemOperand(&MMO, Offset, NarrowSize / 8);
MIRBuilder.materializeGEP(DstReg, MI.getOperand(1).getReg(), OffsetTy,
- Adjustment);
+ Offset);
MIRBuilder.buildStore(SrcRegs[i], DstReg, *SplitMMO);
}
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=352716&r1=352715&r2=352716&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Wed Jan 30 17:49:58 2019
@@ -395,19 +395,18 @@ MachineMemOperand *MachineFunction::getM
MachineMemOperand *
MachineFunction::getMachineMemOperand(const MachineMemOperand *MMO,
int64_t Offset, uint64_t Size) {
- if (MMO->getValue())
- return new (Allocator)
- MachineMemOperand(MachinePointerInfo(MMO->getValue(),
- MMO->getOffset()+Offset),
- MMO->getFlags(), Size, MMO->getBaseAlignment(),
- AAMDNodes(), nullptr, MMO->getSyncScopeID(),
- MMO->getOrdering(), MMO->getFailureOrdering());
+ const MachinePointerInfo &PtrInfo = MMO->getPointerInfo();
+
+ // If there is no pointer value, the offset isn't tracked so we need to adjust
+ // the base alignment.
+ unsigned Align = PtrInfo.V.isNull()
+ ? MinAlign(MMO->getBaseAlignment(), Offset)
+ : MMO->getBaseAlignment();
+
return new (Allocator)
- MachineMemOperand(MachinePointerInfo(MMO->getPseudoValue(),
- MMO->getOffset()+Offset),
- MMO->getFlags(), Size, MMO->getBaseAlignment(),
- AAMDNodes(), nullptr, MMO->getSyncScopeID(),
- MMO->getOrdering(), MMO->getFailureOrdering());
+ MachineMemOperand(PtrInfo.getWithOffset(Offset), MMO->getFlags(), Size,
+ Align, AAMDNodes(), nullptr, MMO->getSyncScopeID(),
+ MMO->getOrdering(), MMO->getFailureOrdering());
}
MachineMemOperand *
More information about the llvm-commits
mailing list