[llvm] [LV] Handle partial sub-reductions with sub in middle block. (PR #178919)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 5 03:41:27 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 |=
----------------
sdesmalen-arm wrote:
This _should_ never happen. Either all operations in the chain should be transformed, or none of them should.
I tried adding an assert here to verify that (no tests failed), but I struggled to construct a test for it (I'm not even sure if we can). I guess it is technically possible for `transformToPartialReduction` to return `false` here (based on what the code is doing), but then the resulting Range must be empty and the VPlan should be discarded, otherwise things would go horribly wrong. Do you know if with a resulting empty Range (and part of the chain using partial reductions), things would still go wrong?
https://github.com/llvm/llvm-project/pull/178919
More information about the llvm-commits
mailing list