Files
TheRock/compiler/amd-llvm/clang/test/CodeGen/RISCV/rvv-builtin-reduce-ops.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

157 lines
4.8 KiB
C

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -triple riscv32 -target-feature +v \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm -o - %s | opt -S -passes=sroa | FileCheck %s
// RUN: %clang_cc1 -triple riscv64 -target-feature +v \
// RUN: -disable-O0-optnone \
// RUN: -emit-llvm -o - %s | opt -S -passes=sroa | FileCheck %s
// REQUIRES: riscv-registered-target
#include <riscv_vector.h>
// Integer reductions — signed
// CHECK-LABEL: @reduce_add_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_ADD:%.*]] = call i32 @llvm.vector.reduce.add.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_ADD]]
//
int reduce_add_i32(vint32m1_t a) {
return __builtin_reduce_add(a);
}
// CHECK-LABEL: @reduce_and_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_AND:%.*]] = call i32 @llvm.vector.reduce.and.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_AND]]
//
int reduce_and_i32(vint32m1_t a) {
return __builtin_reduce_and(a);
}
// CHECK-LABEL: @reduce_or_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_OR:%.*]] = call i32 @llvm.vector.reduce.or.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_OR]]
//
int reduce_or_i32(vint32m1_t a) {
return __builtin_reduce_or(a);
}
// CHECK-LABEL: @reduce_xor_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_XOR:%.*]] = call i32 @llvm.vector.reduce.xor.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_XOR]]
//
int reduce_xor_i32(vint32m1_t a) {
return __builtin_reduce_xor(a);
}
// CHECK-LABEL: @reduce_smax_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MIN:%.*]] = call i32 @llvm.vector.reduce.smax.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_MIN]]
//
int reduce_smax_i32(vint32m1_t a) {
return __builtin_reduce_max(a);
}
// CHECK-LABEL: @reduce_smin_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MIN:%.*]] = call i32 @llvm.vector.reduce.smin.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_MIN]]
//
int reduce_smin_i32(vint32m1_t a) {
return __builtin_reduce_min(a);
}
// Integer reductions — unsigned
// CHECK-LABEL: @reduce_umax_u32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MIN:%.*]] = call i32 @llvm.vector.reduce.umax.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_MIN]]
//
unsigned reduce_umax_u32(vuint32m1_t a) {
return __builtin_reduce_max(a);
}
// CHECK-LABEL: @reduce_umin_u32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MIN:%.*]] = call i32 @llvm.vector.reduce.umin.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_MIN]]
//
unsigned reduce_umin_u32(vuint32m1_t a) {
return __builtin_reduce_min(a);
}
// Floating point reductions
// CHECK-LABEL: @reduce_fmax_f32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MIN:%.*]] = call float @llvm.vector.reduce.fmax.nxv2f32(<vscale x 2 x float> [[A:%.*]])
// CHECK-NEXT: ret float [[RDX_MIN]]
//
float reduce_fmax_f32(vfloat32m1_t a) {
return __builtin_reduce_max(a);
}
// CHECK-LABEL: @reduce_fmin_f32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MIN:%.*]] = call float @llvm.vector.reduce.fmin.nxv2f32(<vscale x 2 x float> [[A:%.*]])
// CHECK-NEXT: ret float [[RDX_MIN]]
//
float reduce_fmin_f32(vfloat32m1_t a) {
return __builtin_reduce_min(a);
}
// CHECK-LABEL: @reduce_fmaximum_f32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MAXIMUM:%.*]] = call float @llvm.vector.reduce.fmaximum.nxv2f32(<vscale x 2 x float> [[A:%.*]])
// CHECK-NEXT: ret float [[RDX_MAXIMUM]]
//
float reduce_fmaximum_f32(vfloat32m1_t a) {
return __builtin_reduce_maximum(a);
}
// CHECK-LABEL: @reduce_fminimum_f32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MINIMUM:%.*]] = call float @llvm.vector.reduce.fminimum.nxv2f32(<vscale x 2 x float> [[A:%.*]])
// CHECK-NEXT: ret float [[RDX_MINIMUM]]
//
float reduce_fminimum_f32(vfloat32m1_t a) {
return __builtin_reduce_minimum(a);
}
// Different LMUL
// CHECK-LABEL: @reduce_add_i32_m8(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_ADD:%.*]] = call i32 @llvm.vector.reduce.add.nxv16i32(<vscale x 16 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_ADD]]
//
int reduce_add_i32_m8(vint32m8_t a) {
return __builtin_reduce_add(a);
}
// Different element width
// CHECK-LABEL: @reduce_add_i64(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_ADD:%.*]] = call i64 @llvm.vector.reduce.add.nxv1i64(<vscale x 1 x i64> [[A:%.*]])
// CHECK-NEXT: ret i64 [[RDX_ADD]]
//
long long reduce_add_i64(vint64m1_t a) {
return __builtin_reduce_add(a);
}
// CHECK-LABEL: @reduce_mul_i32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[RDX_MUL:%.*]] = call i32 @llvm.vector.reduce.mul.nxv2i32(<vscale x 2 x i32> [[A:%.*]])
// CHECK-NEXT: ret i32 [[RDX_MUL]]
//
int reduce_mul_i32(vint32m1_t a) {
return __builtin_reduce_mul(a);
}