[llvm-branch-commits] [llvm] [LV] Only create partial reductions when profitable. (PR #181706)
Florian Hahn via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Mar 12 03:59:01 PDT 2026
================
@@ -6216,10 +6195,17 @@ getScaledReductions(VPReductionPHIRecipe *RedPhiR, VPCostContext &CostCtx,
if (!PHISize.hasKnownScalarFactor(ExtSrcSize))
return std::nullopt;
+ /// Check if a partial reduction chain is supported by the target (i.e.
+ /// does not have an invalid cost) for the given VF range. Clamps the range
+ /// and returns true if feasible for any VF.
VPPartialReductionChain Chain(
{UpdateR, *ExtendedOp,
static_cast<unsigned>(PHISize.getKnownScalarFactor(ExtSrcSize)), RK});
- if (!isValidPartialReduction(Chain, PhiType, CostCtx, Range))
+ if (!LoopVectorizationPlanner::getDecisionAndClampRange(
+ [&](ElementCount VF) {
+ return getPartialReductionLinkCost(CostCtx, Chain, VF).isValid();
----------------
fhahn wrote:
could we store the partial reduction cost as part of chain, to avid re-computing below?
https://github.com/llvm/llvm-project/pull/181706
More information about the llvm-branch-commits
mailing list