[llvm] [VPlan] Don't apply predication discount to non-originally-predicated blocks (PR #160449)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 10 01:16:43 PST 2025


================
@@ -5082,10 +5107,11 @@ InstructionCost LoopVectorizationCostModel::expectedCost(ElementCount VF) {
     // stores and instructions that may divide by zero) will now be
     // unconditionally executed. For the scalar case, we may not always execute
     // the predicated block, if it is an if-else block. Thus, scale the block's
-    // cost by the probability of executing it. blockNeedsPredication from
-    // Legal is used so as to not include all blocks in tail folded loops.
-    if (VF.isScalar() && Legal->blockNeedsPredication(BB))
-      BlockCost /= getPredBlockCostDivisor(CostKind);
+    // cost by the probability of executing it.
+    // getPredBlockCostDivisor won't include blocks that are only predicated due
+    // to tail folded loops
----------------
fhahn wrote:

```suggestion
    // getPredBlockCostDivisor will return 1 for blocks only predicated due
    // by the header mask when folding the tail
```

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


More information about the llvm-commits mailing list