[llvm] [AArch64][CostModel] Lower wide fixed-length vector reductions cost (PR #211824)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 08:26:16 PDT 2026


================
@@ -0,0 +1,280 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" 2>&1 -disable-output \
+; RUN:    -cost-kind=all -aarch64-sve-vector-bits-min=128 \
+; RUN:    | FileCheck %s --check-prefixes=VSCALE-1
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" 2>&1 -disable-output \
+; RUN:    -cost-kind=all -aarch64-sve-vector-bits-min=128 -aarch64-sve-vector-bits-max=128 \
+; RUN:    | FileCheck %s --check-prefixes=VSCALE-1
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" 2>&1 -disable-output \
+; RUN:    -cost-kind=all -aarch64-sve-vector-bits-min=256 \
+; RUN:    | FileCheck %s --check-prefixes=VSCALE-2
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" 2>&1 -disable-output \
+; RUN:    -cost-kind=all -aarch64-sve-vector-bits-min=256 -aarch64-sve-vector-bits-max=256 \
+; RUN:    | FileCheck %s --check-prefixes=VSCALE-2
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" 2>&1 -disable-output \
+; RUN:    -cost-kind=all -aarch64-sve-vector-bits-min=512 \
+; RUN:    | FileCheck %s --check-prefixes=VSCALE-4
+; RUN: opt < %s -mtriple=aarch64 -mattr=+sve -passes="print<cost-model>" 2>&1 -disable-output \
+; RUN:    -cost-kind=all -aarch64-sve-vector-bits-min=512 -aarch64-sve-vector-bits-max=512 \
+; RUN:    | FileCheck %s --check-prefixes=VSCALE-4
+
+; This tests the cost of fixed-length reductions for SVE,
+; either for a minimum vscale or a fixed vscale (aka VLS).
+; For the NEON equivalent test, see reduce-*.ll
+; Codegen tests are in sve-fixed-length-int-reduce.ll
+
+define void @reduce_add() {
+; VSCALE-1-LABEL: 'reduce_add'
+; VSCALE-1-NEXT:  Cost Model: Found costs of 2 for: %V16i8 = call i8 @llvm.vector.reduce.add.v16i8(<16 x i8> poison)
----------------
gbossu wrote:

I am tempted to split those tests into e.g. `reduce_add_128`, `reduce_add_256` and `reduce_add_512` to better show that 128-bit vectors have the same costs for all vscale values and 256-bit vectors have the same costs on vscale values >= 2.

https://github.com/llvm/llvm-project/pull/211824


More information about the llvm-commits mailing list