[llvm] 41f3438 - [VPlan] Remove dead code for scalar VFs in VPRegionBlock::cost (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 28 09:31:31 PDT 2025


Author: Florian Hahn
Date: 2025-09-28T17:30:57+01:00
New Revision: 41f3438362f5ae2a06544fec7db18c37f5ecd79b

URL: https://github.com/llvm/llvm-project/commit/41f3438362f5ae2a06544fec7db18c37f5ecd79b
DIFF: https://github.com/llvm/llvm-project/commit/41f3438362f5ae2a06544fec7db18c37f5ecd79b.diff

LOG: [VPlan] Remove dead code for scalar VFs in VPRegionBlock::cost (NFC).

The VPlan cost model is not used to compute costs of scalar VFs
currently, as conversion to replicate regions makes accurately computing
the original scalar cost difficult.

Remove left over, dead code.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlan.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index a1c6f7977885f..81f1956c96254 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -845,19 +845,10 @@ InstructionCost VPRegionBlock::cost(ElementCount VF, VPCostContext &Ctx) {
   if (VF.isScalable())
     return InstructionCost::getInvalid();
 
-  // First compute the cost of the conditionally executed recipes, followed by
-  // account for the branching cost, except if the mask is a header mask or
-  // uniform condition.
-  using namespace llvm::VPlanPatternMatch;
+  // Compute and return the cost of the conditionally executed recipes.
+  assert(VF.isVector() && "Can only compute vector cost at the moment.");
   VPBasicBlock *Then = cast<VPBasicBlock>(getEntry()->getSuccessors()[0]);
-  InstructionCost ThenCost = Then->cost(VF, Ctx);
-
-  // For the scalar case, we may not always execute the original predicated
-  // block, Thus, scale the block's cost by the probability of executing it.
-  if (VF.isScalar())
-    return ThenCost / getPredBlockCostDivisor(Ctx.CostKind);
-
-  return ThenCost;
+  return Then->cost(VF, Ctx);
 }
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)


        


More information about the llvm-commits mailing list