[clang] [CIR] Lowering for __builtin_reduce_add/mul/min/max/in_order_fadd (PR #224204)

Kunal Dubey via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 22:03:38 PDT 2026


================
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -target-feature +sve \
+// RUN:   -fclangir -emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -target-feature +sve \
+// RUN:   -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -target-feature +sve \
+// RUN:   -emit-llvm %s -o %t.ll
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
+//
+// REQUIRES: aarch64-registered-target
+
+#include <arm_sve.h>
+
+int test_sve_reduce_max(svint32_t x) {
+  // CIR-LABEL: @test_sve_reduce_max
+  // CIR: cir.call_llvm_intrinsic "vector.reduce.smax"
+  // CIR: cir.return
+  // LLVM-LABEL: @test_sve_reduce_max
+  // LLVM: call i32 @llvm.vector.reduce.smax.nxv4i32(<vscale x 4 x i32>
+  // LLVM: ret i32
+  return __builtin_reduce_max(x);
+}
+
+unsigned test_sve_reduce_max_unsigned(svuint32_t x) {
+  // CIR-LABEL: @test_sve_reduce_max_unsigned
+  // CIR: cir.call_llvm_intrinsic "vector.reduce.umax"
+  // CIR: cir.return
+  // LLVM-LABEL: @test_sve_reduce_max_unsigned
+  // LLVM: call i32 @llvm.vector.reduce.umax.nxv4i32(<vscale x 4 x i32>
+  // LLVM: ret i32
+  return __builtin_reduce_max(x);
+}
+
+float test_sve_reduce_max_float(svfloat32_t x) {
----------------
xakep8 wrote:

I'll add these.

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


More information about the cfe-commits mailing list