Skip to content

Commit 8875c32

Browse files
committed
[Fix] Replace getLoadStorePointerOperand with Ptr->getUnderlyingValue().
1 parent 025f530 commit 8875c32

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
@@ -2536,6 +2536,14 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan, VPCostContext &Ctx,
25362536
if (!MemR || !isa<VPWidenLoadRecipe>(MemR) || !MemR->isReverse())
25372537
continue;
25382538

2539+
auto *VecEndPtr = cast<VPVectorEndPointerRecipe>(MemR->getAddr());
2540+
VPValue *Ptr = VecEndPtr->getPtr();
2541+
Value *PtrUV = Ptr->getUnderlyingValue();
2542+
// Memory cost model requires the pointer operand of memory access
2543+
// instruction.
2544+
if (!PtrUV)
2545+
continue;
2546+
25392547
Instruction &Ingredient = MemR->getIngredient();
25402548
Type *ElementTy = getLoadStoreType(&Ingredient);
25412549

@@ -2546,10 +2554,9 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan, VPCostContext &Ctx,
25462554
return false;
25472555
const InstructionCost CurrentCost = MemR->computeCost(VF, Ctx);
25482556
const InstructionCost StridedLoadStoreCost =
2549-
Ctx.TTI.getStridedMemoryOpCost(
2550-
Instruction::Load, DataTy,
2551-
getLoadStorePointerOperand(&Ingredient), MemR->isMasked(),
2552-
Alignment, Ctx.CostKind, &Ingredient);
2557+
Ctx.TTI.getStridedMemoryOpCost(Instruction::Load, DataTy, PtrUV,
2558+
MemR->isMasked(), Alignment,
2559+
Ctx.CostKind, &Ingredient);
25532560
return StridedLoadStoreCost < CurrentCost;
25542561
};
25552562

@@ -2559,10 +2566,7 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan, VPCostContext &Ctx,
25592566

25602567
// The stride of consecutive reverse access must be -1.
25612568
int64_t Stride = -1;
2562-
auto *VecEndPtr = cast<VPVectorEndPointerRecipe>(MemR->getAddr());
2563-
VPValue *Ptr = VecEndPtr->getPtr();
2564-
auto *GEP = dyn_cast<GetElementPtrInst>(
2565-
Ptr->getUnderlyingValue()->stripPointerCasts());
2569+
auto *GEP = dyn_cast<GetElementPtrInst>(PtrUV->stripPointerCasts());
25662570
// Create a new vector pointer for strided access.
25672571
auto *NewPtr = new VPVectorPointerRecipe(Ptr, ElementTy, /*Stride=*/true,
25682572
GEP ? GEP->getNoWrapFlags()

0 commit comments

Comments
 (0)