[llvm] [VPlan] Return invalid cost if any skeleton block has invalid costs. (PR #151940)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 04:01:08 PDT 2025


================
@@ -1072,9 +1072,13 @@ InstructionCost VPlan::cost(ElementCount VF, VPCostContext &Ctx) {
   // blocks, like the preheader or middle blocks.
   InstructionCost Cost = getVectorLoopRegion()->cost(VF, Ctx);
 
-  // If any instructions in the middle block are invalid return invalid.
-  // TODO: Remove once no VPlans with VF == vscale x 1 and first-order recurrences are created.
-  if (!getMiddleBlock()->cost(VF, Ctx).isValid())
+  // If any instructions in the skeleton outside loop regions are invalid return
+  // invalid.
+  if (any_of(VPBlockUtils::blocksOnly<VPBasicBlock>(
+                 vp_depth_first_shallow(getEntry())),
+             [&VF, &Ctx](VPBasicBlock *VPBB) {
----------------
artagnon wrote:

```suggestion
             [&VF, &Ctx](const VPBasicBlock *VPBB) {
```

Nit. I hope cost() is marked cost?

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


More information about the llvm-commits mailing list