[llvm] [SLP]Allow min-VF vectorization of seed-level reduction groups (PR #222757)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 04:53:24 PDT 2026
================
@@ -30644,11 +30657,24 @@ class HorizontalReduction {
}
unsigned NumReducedVals = Candidates.size();
+ auto UsedByReductionOnly = [&](Value *V) {
+ if (!V->hasUseList())
+ return true;
+ // Bail out if we have too many uses to save compilation time.
+ if (V->hasNUsesOrMore(UsesLimit))
+ return false;
+ return all_of(V->users(),
+ [&](User *U) { return IgnoreList.contains(U); });
+ };
// Sign-aware reductions pair small positive/negative groups: allow
- // non-splat groups down to 2 elements.
+ // non-splat groups down to 2 elements. Seed-level reductions get the
+ // same for groups whose values are used by the reduction operations
+ // only, if the minimum vector factor covers the whole reduction.
+ const bool MinVFAllowed = IsSeedRoot && NoScalarLeftovers &&
+ all_of(Candidates, UsedByReductionOnly);
----------------
MrSidims wrote:
There is no RdxKind check here. The description and the ordering comment talk about groups that would otherwise fall through to the ordered reduction, but that fallback only exists for fadd. For fmul and integer reductions trunk leaves these pairs scalar, so for them this is new vectorization, not a better fallback.
So we should either restrict usage only for fadd or update comments.
https://github.com/llvm/llvm-project/pull/222757
More information about the llvm-commits
mailing list