[llvm] [AArch64] Fold four and eight way partial reductions with [SU]ADDLP (PR #214636)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 04:31:04 PDT 2026
================
@@ -13984,6 +13984,51 @@ SDValue TargetLowering::expandPartialReduceMLA(SDNode *N,
break;
}
+ // A wide partial reduction is built from a ladder of narrower ones, a rung
+ // at a time, each halving the element count and doubling the width.
+ unsigned Opc = N->getOpcode();
+ ElementCount MulEC = MulOpVT.getVectorElementCount();
+ ElementCount AccEC = AccVT.getVectorElementCount();
+ unsigned CountRatio =
+ MulEC.hasKnownScalarFactor(AccEC) ? MulEC.getKnownScalarFactor(AccEC) : 0;
+ unsigned WidthRatio =
+ AccVT.getScalarSizeInBits() / MulOpVT.getScalarSizeInBits();
+ if (Opc != ISD::PARTIAL_REDUCE_FMLA && CountRatio > 2 &&
+ 2 * WidthRatio >= CountRatio) {
----------------
paulwalker-arm wrote:
It still feels odd linking an element type restriction to the element count. Essentially this check is asking "Will the partial_reduce_mla nodes be valid if I widen the element type?".
If I replace `2 * WidthRatio >= CountRatio` with `WidthRatio >= 2` the tests all still pass?
https://github.com/llvm/llvm-project/pull/214636
More information about the llvm-commits
mailing list