[llvm] [VPlan] Reject partial reductions with invalid costs in getScaledReds. (PR #180438)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 9 02:24:22 PST 2026


================
@@ -5813,13 +5802,13 @@ void VPlanTransforms::createPartialReductions(VPlan &Plan,
     // Get the backedge value from the reduction PHI and find the
     // ComputeReductionResult that uses it (directly or through a select for
     // predicated reductions).
-    if (auto *RdxResult = vputils::findComputeReductionResult(RedPhiR)) {
-      VPValue *ExitValue = RdxResult->getOperand(0);
-      match(ExitValue,
-            m_Select(m_VPValue(), m_VPValue(ExitValue), m_VPValue()));
-      getScaledReductions(RedPhiR, ExitValue, ChainsByPhi[RedPhiR],
-                          CostCtx.Types);
-    }
+    auto *RdxResult = vputils::findComputeReductionResult(RedPhiR);
+    if (!RdxResult)
+      continue;
+    VPValue *ExitValue = RdxResult->getOperand(0);
+    match(ExitValue, m_Select(m_VPValue(), m_VPValue(ExitValue), m_VPValue()));
+    getScaledReductions(RedPhiR, ExitValue, ChainsByPhi[RedPhiR], CostCtx,
+                        Range);
----------------
sdesmalen-arm wrote:

With the exception of the arguments passed to `getScaledReductions`, this seems like a largely NFC change? Please separate such changes out from the fix to make it easier to review.

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


More information about the llvm-commits mailing list