1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
4 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
5 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
6 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
7 
8 #include <arm_sve.h>
9 
10 #ifdef SVE_OVERLOADED_FORMS
11 // A simple used,unused... macro, long enough to represent any SVE builtin.
12 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
13 #else
14 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
15 #endif
16 
test_svmaxnmv_f16(svbool_t pg,svfloat16_t op)17 float16_t test_svmaxnmv_f16(svbool_t pg, svfloat16_t op)
18 {
19   // CHECK-LABEL: test_svmaxnmv_f16
20   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
21   // CHECK: %[[INTRINSIC:.*]] = call half @llvm.aarch64.sve.fmaxnmv.nxv8f16(<vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op)
22   // CHECK: ret half %[[INTRINSIC]]
23   return SVE_ACLE_FUNC(svmaxnmv,_f16,,)(pg, op);
24 }
25 
test_svmaxnmv_f32(svbool_t pg,svfloat32_t op)26 float32_t test_svmaxnmv_f32(svbool_t pg, svfloat32_t op)
27 {
28   // CHECK-LABEL: test_svmaxnmv_f32
29   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
30   // CHECK: %[[INTRINSIC:.*]] = call float @llvm.aarch64.sve.fmaxnmv.nxv4f32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op)
31   // CHECK: ret float %[[INTRINSIC]]
32   return SVE_ACLE_FUNC(svmaxnmv,_f32,,)(pg, op);
33 }
34 
test_svmaxnmv_f64(svbool_t pg,svfloat64_t op)35 float64_t test_svmaxnmv_f64(svbool_t pg, svfloat64_t op)
36 {
37   // CHECK-LABEL: test_svmaxnmv_f64
38   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
39   // CHECK: %[[INTRINSIC:.*]] = call double @llvm.aarch64.sve.fmaxnmv.nxv2f64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op)
40   // CHECK: ret double %[[INTRINSIC]]
41   return SVE_ACLE_FUNC(svmaxnmv,_f64,,)(pg, op);
42 }
43