[llvm] [X86][LV] Add partial-reduction dot-product support (PR #205373)
Zihao Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 24 08:29:32 PDT 2026
hhy3 wrote:
@fhahn split into two seperate commits
LoopVectorize currently caps candidate VFs using the widest element type seen in the loop. Dot-product reductions widen narrow inputs, such as i8, i16, or bf16, into i32/f32 recurrence values before the reduction update. Treating the widened recurrence type as the loop's effective widest type can keep the selected VF too small even when the target can lower the recurrence as a partial reduction.
A partial reduction consumes VF input lanes into VF / scale accumulator lanes. When every loop use of a recurrence chain is representable by the VPlan partial-reduction transform, and the widened recurrence type is not also required by non-reduction operations, use the narrow input type as the effective width for VF selection. Keep the original widest type for dependence-distance and store-load forwarding safety checks, because those are based on the actual memory-access widths.
The IR-level matcher is intentionally conservative and mirrors the VPlan partial-reduction matcher. It also probes the target partial-reduction cost hook before narrowing, so generic LV only changes VF selection for shapes the target reports as supported.
https://github.com/llvm/llvm-project/pull/205373
More information about the llvm-commits
mailing list