Skip to content

Commit 523c796

Browse files
committed
[VPlan] Use VPlan type inference to get address space for recipes. (NFC)
Instead of accessing the address space from the IR reference, retrieve it via type inference.
1 parent 4a660c7 commit 523c796

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,7 +3358,7 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
33583358
Type *ValTy = Ctx.Types.inferScalarType(IsLoad ? this : getOperand(0));
33593359
Type *ScalarPtrTy = Ctx.Types.inferScalarType(PtrOp);
33603360
const Align Alignment = getLoadStoreAlignment(UI);
3361-
unsigned AS = getLoadStoreAddressSpace(UI);
3361+
unsigned AS = cast<PointerType>(ScalarPtrTy)->getAddressSpace();
33623362
TTI::OperandValueInfo OpInfo = TTI::getOperandInfo(UI->getOperand(0));
33633363
InstructionCost ScalarMemOpCost = Ctx.TTI.getMemoryOpCost(
33643364
UI->getOpcode(), ValTy, Alignment, AS, Ctx.CostKind, OpInfo);
@@ -3675,7 +3675,8 @@ InstructionCost VPWidenLoadEVLRecipe::computeCost(ElementCount VF,
36753675
// don't need to compare to the legacy cost model.
36763676
Type *Ty = toVectorTy(getLoadStoreType(&Ingredient), VF);
36773677
const Align Alignment = getLoadStoreAlignment(&Ingredient);
3678-
unsigned AS = getLoadStoreAddressSpace(&Ingredient);
3678+
unsigned AS = cast<PointerType>(Ctx.Types.inferScalarType(getAddr()))
3679+
->getAddressSpace();
36793680
InstructionCost Cost = Ctx.TTI.getMaskedMemoryOpCost(
36803681
Instruction::Load, Ty, Alignment, AS, Ctx.CostKind);
36813682
if (!Reverse)
@@ -3786,7 +3787,8 @@ InstructionCost VPWidenStoreEVLRecipe::computeCost(ElementCount VF,
37863787
// don't need to compare to the legacy cost model.
37873788
Type *Ty = toVectorTy(getLoadStoreType(&Ingredient), VF);
37883789
const Align Alignment = getLoadStoreAlignment(&Ingredient);
3789-
unsigned AS = getLoadStoreAddressSpace(&Ingredient);
3790+
unsigned AS = cast<PointerType>(Ctx.Types.inferScalarType(getAddr()))
3791+
->getAddressSpace();
37903792
InstructionCost Cost = Ctx.TTI.getMaskedMemoryOpCost(
37913793
Instruction::Store, Ty, Alignment, AS, Ctx.CostKind);
37923794
if (!Reverse)
@@ -4252,7 +4254,8 @@ InstructionCost VPInterleaveBase::computeCost(ElementCount VF,
42524254
getNumDefinedValues() > 0 ? getVPValue(InsertPosIdx)
42534255
: getStoredValues()[InsertPosIdx]);
42544256
auto *VectorTy = cast<VectorType>(toVectorTy(ValTy, VF));
4255-
unsigned AS = getLoadStoreAddressSpace(InsertPos);
4257+
unsigned AS = cast<PointerType>(Ctx.Types.inferScalarType(getAddr()))
4258+
->getAddressSpace();
42564259

42574260
unsigned InterleaveFactor = IG->getFactor();
42584261
auto *WideVecTy = VectorType::get(ValTy, VF * InterleaveFactor);

0 commit comments

Comments
 (0)