[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 04:01:33 PST 2024
================
@@ -9019,6 +9152,15 @@ 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
+ for (const auto &[Phi, RdxDesc] : Legal->getReductionVars())
+ if (std::optional<PartialReductionChain> Chain =
+ getScaledReduction(Phi, RdxDesc, &TTI, Range, CM))
+ RecipeBuilder.addScaledReductionExitInstr(*Chain);
+ RecipeBuilder.removeInvalidScaledReductionExitInstrs();
----------------
fhahn wrote:
Or move the whole loop to collect the exit instrs & the invalidation to a function in recipe builder if possible?
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list