[llvm] [VPlan] Sink retrieving legacy costs to more specific computeCost impls. (PR #109708)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 05:50:03 PDT 2024
================
@@ -274,33 +274,28 @@ void VPRecipeBase::moveBefore(VPBasicBlock &BB,
insertBefore(BB, I);
}
-/// Return the underlying instruction to be used for computing \p R's cost via
-/// the legacy cost model. Return nullptr if there's no suitable instruction.
-static Instruction *getInstructionForCost(const VPRecipeBase *R) {
- if (auto *S = dyn_cast<VPSingleDefRecipe>(R))
- return dyn_cast_or_null<Instruction>(S->getUnderlyingValue());
- if (auto *IG = dyn_cast<VPInterleaveRecipe>(R))
- return IG->getInsertPos();
- // Currently the legacy cost model only calculates the instruction cost with
- // underlying instruction. Removing the WidenMem here will prevent
- // force-target-instruction-cost overwriting the cost of recipe with
- // underlying instruction which is inconsistent with the legacy model.
- // TODO: Remove WidenMem from this function when we don't need to compare to
- // the legacy model.
- if (auto *WidenMem = dyn_cast<VPWidenMemoryRecipe>(R))
- return &WidenMem->getIngredient();
- return nullptr;
-}
-
InstructionCost VPRecipeBase::cost(ElementCount VF, VPCostContext &Ctx) {
- auto *UI = getInstructionForCost(this);
- if (UI && Ctx.skipCostComputation(UI, VF.isVector()))
- return 0;
-
- InstructionCost RecipeCost = computeCost(VF, Ctx);
- if (UI && ForceTargetInstructionCost.getNumOccurrences() > 0 &&
- RecipeCost.isValid())
- RecipeCost = InstructionCost(ForceTargetInstructionCost);
+ // Get the underlying instruction for the recipe, if there is one. Is is used
----------------
fhahn wrote:
Fixed, thanks!
https://github.com/llvm/llvm-project/pull/109708
More information about the llvm-commits
mailing list