Skip to content

Commit 40c3ba6

Browse files
committed
[Fix] Replace getLoadStorePointerOperand with Ptr->getUnderlyingValue().
1 parent fc45ca2 commit 40c3ba6

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,14 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan, VPCostContext &Ctx,
25442544
if (!MemR || !isa<VPWidenLoadRecipe>(MemR) || !MemR->isReverse())
25452545
continue;
25462546

2547+
auto *VecEndPtr = cast<VPVectorEndPointerRecipe>(MemR->getAddr());
2548+
VPValue *Ptr = VecEndPtr->getPtr();
2549+
Value *PtrUV = Ptr->getUnderlyingValue();
2550+
// Memory cost model requires the pointer operand of memory access
2551+
// instruction.
2552+
if (!PtrUV)
2553+
continue;
2554+
25472555
Instruction &Ingredient = MemR->getIngredient();
25482556
Type *ElementTy = getLoadStoreType(&Ingredient);
25492557

@@ -2554,10 +2562,9 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan, VPCostContext &Ctx,
25542562
return false;
25552563
const InstructionCost CurrentCost = MemR->computeCost(VF, Ctx);
25562564
const InstructionCost StridedLoadStoreCost =
2557-
Ctx.TTI.getStridedMemoryOpCost(
2558-
Instruction::Load, DataTy,
2559-
getLoadStorePointerOperand(&Ingredient), MemR->isMasked(),
2560-
Alignment, Ctx.CostKind, &Ingredient);
2565+
Ctx.TTI.getStridedMemoryOpCost(Instruction::Load, DataTy, PtrUV,
2566+
MemR->isMasked(), Alignment,
2567+
Ctx.CostKind, &Ingredient);
25612568
return StridedLoadStoreCost < CurrentCost;
25622569
};
25632570

@@ -2567,10 +2574,7 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan, VPCostContext &Ctx,
25672574

25682575
// The stride of consecutive reverse access must be -1.
25692576
int64_t Stride = -1;
2570-
auto *VecEndPtr = cast<VPVectorEndPointerRecipe>(MemR->getAddr());
2571-
VPValue *Ptr = VecEndPtr->getPtr();
2572-
auto *GEP = dyn_cast<GetElementPtrInst>(
2573-
Ptr->getUnderlyingValue()->stripPointerCasts());
2577+
auto *GEP = dyn_cast<GetElementPtrInst>(PtrUV->stripPointerCasts());
25742578
// Create a new vector pointer for strided access.
25752579
auto *NewPtr = new VPVectorPointerRecipe(Ptr, ElementTy, /*Stride=*/true,
25762580
GEP ? GEP->getNoWrapFlags()

0 commit comments

Comments
 (0)