[llvm] [VPlan] Add legal checks in VPWidenMemoryRecipe::computeCost(). NFC (PR #110445)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 29 17:42:34 PDT 2024
https://github.com/ElvisWang123 created https://github.com/llvm/llvm-project/pull/110445
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 a valid cost by `TTI.getGatherScatterOpCost`.
Fixing the gap can prevent potentail failure in the future.
>From 987ecd845a0d920c8a3465db672e856420aaa11c Mon Sep 17 00:00:00 2001
From: Elvis Wang <elvis.wang at sifive.com>
Date: Fri, 27 Sep 2024 00:04:27 -0700
Subject: [PATCH] [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.
---
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 2f0ba5510b8f34..c941479e7c6589 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2148,6 +2148,11 @@ InstructionCost VPWidenMemoryRecipe::computeCost(ElementCount VF,
const Value *Ptr = getLoadStorePointerOperand(&Ingredient);
assert(!Reverse &&
"Inconsecutive memory access should not have the order.");
+ if ((isa<LoadInst>(Ingredient) &&
+ !Ctx.TTI.isLegalMaskedGather(Ty, Alignment)) ||
+ (isa<StoreInst>(Ingredient) &&
+ !Ctx.TTI.isLegalMaskedScatter(Ty, Alignment)))
+ return InstructionCost::getInvalid();
return Ctx.TTI.getAddressComputationCost(Ty) +
Ctx.TTI.getGatherScatterOpCost(Ingredient.getOpcode(), Ty, Ptr,
IsMasked, Alignment, CostKind,
More information about the llvm-commits
mailing list