Skip to content

Commit 987ecd8

Browse files
committed
[VPlan] Add legal checks in VPWidenMemoryRecipe::computeCost(). NFC
Add legal checks in the vplan-based cost model that align to the legacy cost model (setCostBasedWideningDecision()). This is patch is not quite a NFC patch but currently we don't have a target that support `ActiveVectorLength && ScalableVector` but not support `gather/scatter` nor return valid cost by `TTI.getGatherScatterOpCost`. Fixing the gap can prevent potentail failure in the future.
1 parent 30f5a3c commit 987ecd8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,11 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
21482148
const Value *Ptr = getLoadStorePointerOperand(&Ingredient);
21492149
assert(!Reverse &&
21502150
"Inconsecutive memory access should not have the order.");
2151+
if ((isa<LoadInst>(Ingredient) &&
2152+
!Ctx.TTI.isLegalMaskedGather(Ty, Alignment)) ||
2153+
(isa<StoreInst>(Ingredient) &&
2154+
!Ctx.TTI.isLegalMaskedScatter(Ty, Alignment)))
2155+
return InstructionCost::getInvalid();
21512156
return Ctx.TTI.getAddressComputationCost(Ty) +
21522157
Ctx.TTI.getGatherScatterOpCost(Ingredient.getOpcode(), Ty, Ptr,
21532158
IsMasked, Alignment, CostKind,

0 commit comments

Comments
 (0)