[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 02:29:11 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);
----------------
SamTebbs33 wrote:
Done.
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list