[llvm] [LV] Handle partial sub-reductions with sub in middle block. (PR #178919)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 04:06:09 PST 2026


================
@@ -5828,7 +5833,46 @@ void VPlanTransforms::createPartialReductions(VPlan &Plan,
     }
   }
 
-  for (const auto &[_, Chains] : ChainsByPhi)
+  for (auto &[Phi, Chains] : ChainsByPhi) {
+    RecurKind RK = cast<VPReductionPHIRecipe>(Phi)->getRecurrenceKind();
+    bool IsTransformed = false;
     for (const VPPartialReductionChain &Chain : Chains)
-      transformToPartialReduction(Chain, Range, CostCtx, Plan);
+      IsTransformed |=
----------------
huntergr-arm wrote:

I agree it should never happen, but using `|=` made me wonder a bit. An empty range will result in an assert, but if the result is the same at all VFs it won't clamp. We just wouldn't perform the transform.

The check before the clamp as to whether the constant can be extended might be a possible problem? If one chain extended from 16b and a second from 8b, maybe we would get a difference? Hopefully we wouldn't form a chain in the first place though.

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


More information about the llvm-commits mailing list