Skip to content

Commit c324fc5

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 af47038 commit c324fc5

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
@@ -2237,6 +2237,11 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
22372237
const Value *Ptr = getLoadStorePointerOperand(&Ingredient);
22382238
assert(!Reverse &&
22392239
"Inconsecutive memory access should not have the order.");
2240+
if ((isa<LoadInst>(Ingredient) &&
2241+
!Ctx.TTI.isLegalMaskedGather(Ty, Alignment)) ||
2242+
(isa<StoreInst>(Ingredient) &&
2243+
!Ctx.TTI.isLegalMaskedScatter(Ty, Alignment)))
2244+
return InstructionCost::getInvalid();
22402245
return Ctx.TTI.getAddressComputationCost(Ty) +
22412246
Ctx.TTI.getGatherScatterOpCost(Ingredient.getOpcode(), Ty, Ptr,
22422247
IsMasked, Alignment, CostKind,

0 commit comments

Comments
 (0)