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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 07:41:25 PDT 2025


================
@@ -855,7 +855,9 @@ InstructionCost VPRegionBlock::cost(ElementCount VF, VPCostContext &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);
+    if (auto *VPIRBB = dyn_cast<VPIRBasicBlock>(Then))
----------------
david-arm wrote:

This change doesn't look right, since we know from the code above that `Then` is always a VPBasicBlock. The only way to make this work is to map the recipe back to the original scalar instruction and find it's parent.

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


More information about the llvm-commits mailing list