[llvm-branch-commits] [llvm] [LV] Only create partial reductions when profitable. (PR #181706)

Florian Hahn via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 16 04:28:51 PDT 2026


================
@@ -6216,20 +6195,20 @@ getScaledReductions(VPReductionPHIRecipe *RedPhiR, VPCostContext &CostCtx,
     if (!PHISize.hasKnownScalarFactor(ExtSrcSize))
       return std::nullopt;
 
-    VPPartialReductionChain Chain(
+    // Check if a partial reduction chain is supported by the target (i.e. does
+    // not have an invalid cost) for the given VF range. Clamps the range and
+    // returns true if feasible for any VF.
+    VPPartialReductionChain Link(
         {UpdateR, *ExtendedOp,
          static_cast<unsigned>(PHISize.getKnownScalarFactor(ExtSrcSize)), RK});
-    if (!isValidPartialReduction(Chain, PhiType, CostCtx, Range))
-      return std::nullopt;
-
-    Chains.push_back(Chain);
+    Chain.push_back(Link);
     CurrentValue = PrevValue;
   }
 
   // The chains were collected by traversing backwards from the exit value.
----------------
fhahn wrote:

```suggestion
  // The links of Chain were collected by traversing backwards from the exit value.
```

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


More information about the llvm-branch-commits mailing list