[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Sam Tebbs via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 09:14:21 PST 2024
================
@@ -8663,6 +8663,113 @@ VPReplicateRecipe *VPRecipeBuilder::handleReplication(Instruction *I,
return Recipe;
}
+void VPRecipeBuilder::collectScaledReductions(VFRange &Range) {
+ // Find all possible partial reductions
+ SmallVector<PartialReductionChain, 1> PartialReductionChains;
+ for (const auto &[Phi, RdxDesc] : Legal->getReductionVars())
+ if (std::optional<PartialReductionChain> Chain =
+ getScaledReduction(Phi, RdxDesc, Range))
+ PartialReductionChains.push_back(*Chain);
+
+ // A partial reduction is invalid if any of its extends are used by
+ // something that isn't another partial reduction. This is because the
+ // extends are intended to be lowered along with the reduction itself.
----------------
SamTebbs33 wrote:
I've looked into what the assembly looks like if we remove the restriction, and it looks pretty bad so I think removing the restriction should come in a future patch with additional work on the cost model.
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list