[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


================
@@ -311,10 +306,12 @@ InstructionCost VPRecipeBase::cost(ElementCount VF, VPCostContext &Ctx) {
 
 InstructionCost VPRecipeBase::computeCost(ElementCount VF,
                                           VPCostContext &Ctx) const {
-  // Compute the cost for the recipe falling back to the legacy cost model using
-  // the underlying instruction. If there is no underlying instruction, returns
-  // 0.
-  Instruction *UI = getInstructionForCost(this);
+  llvm_unreachable("subclasses should implement computeCost");
+}
+
+InstructionCost VPSingleDefRecipe::computeCost(ElementCount VF,
+                                               VPCostContext &Ctx) const {
+  Instruction *UI = dyn_cast_or_null<Instruction>(getUnderlyingValue());
   if (UI && isa<VPReplicateRecipe>(this)) {
----------------
fhahn wrote:

Done, thanks!

https://github.com/llvm/llvm-project/pull/109708


More information about the llvm-commits mailing list