[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 10 12:39:45 PST 2024
================
@@ -9087,6 +9218,16 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
bool NeedsBlends = BB != HeaderBB && !BB->phis().empty();
return Legal->blockNeedsPredication(BB) || NeedsBlends;
});
+
+ // Cache the partial reductions up front so we can remove the invalid ones
+ // before creating the recipes
+ SmallVector<PartialReductionChain, 1> PartialReductionChains;
+ for (const auto &[Phi, RdxDesc] : Legal->getReductionVars())
+ if (std::optional<PartialReductionChain> Chain =
+ getScaledReduction(Phi, RdxDesc, &TTI, Range, CM))
+ PartialReductionChains.push_back(*Chain);
+ RecipeBuilder.addScaledReductionExitInstrs(PartialReductionChains);
----------------
fhahn wrote:
Would probably still be good to keep all logic to collect partial reductions in VPRecipeBuilder and have a single VPRecipeBuilder::collectScaledReductions if possible
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list