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 -o - %s >/dev/null
7 #include <arm_sve.h>
8 
9 #ifdef SVE_OVERLOADED_FORMS
10 // A simple used,unused... macro, long enough to represent any SVE builtin.
11 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
12 #else
13 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
14 #endif
15 
test_svacgt_f16(svbool_t pg,svfloat16_t op1,svfloat16_t op2)16 svbool_t test_svacgt_f16(svbool_t pg, svfloat16_t op1, svfloat16_t op2)
17 {
18   // CHECK-LABEL: test_svacgt_f16
19   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
20   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.facgt.nxv8f16(<vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op1, <vscale x 8 x half> %op2)
21   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %[[INTRINSIC]])
22   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
23   return SVE_ACLE_FUNC(svacgt,_f16,,)(pg, op1, op2);
24 }
25 
test_svacgt_f32(svbool_t pg,svfloat32_t op1,svfloat32_t op2)26 svbool_t test_svacgt_f32(svbool_t pg, svfloat32_t op1, svfloat32_t op2)
27 {
28   // CHECK-LABEL: test_svacgt_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 <vscale x 4 x i1> @llvm.aarch64.sve.facgt.nxv4f32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op1, <vscale x 4 x float> %op2)
31   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %[[INTRINSIC]])
32   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
33   return SVE_ACLE_FUNC(svacgt,_f32,,)(pg, op1, op2);
34 }
35 
test_svacgt_f64(svbool_t pg,svfloat64_t op1,svfloat64_t op2)36 svbool_t test_svacgt_f64(svbool_t pg, svfloat64_t op1, svfloat64_t op2)
37 {
38   // CHECK-LABEL: test_svacgt_f64
39   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
40   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.facgt.nxv2f64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op1, <vscale x 2 x double> %op2)
41   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %[[INTRINSIC]])
42   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
43   return SVE_ACLE_FUNC(svacgt,_f64,,)(pg, op1, op2);
44 }
45 
test_svacgt_n_f32(svbool_t pg,svfloat32_t op1,float32_t op2)46 svbool_t test_svacgt_n_f32(svbool_t pg, svfloat32_t op1, float32_t op2)
47 {
48   // CHECK-LABEL: test_svacgt_n_f32
49   // CHECK-DAG: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
50   // CHECK-DAG: %[[DUP:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.dup.x.nxv4f32(float %op2)
51   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.facgt.nxv4f32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op1, <vscale x 4 x float> %[[DUP]])
52   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %[[INTRINSIC]])
53   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
54   return SVE_ACLE_FUNC(svacgt,_n_f32,,)(pg, op1, op2);
55 }
56 
test_svacgt_n_f64(svbool_t pg,svfloat64_t op1,float64_t op2)57 svbool_t test_svacgt_n_f64(svbool_t pg, svfloat64_t op1, float64_t op2)
58 {
59   // CHECK-LABEL: test_svacgt_n_f64
60   // CHECK-DAG: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
61   // CHECK-DAG: %[[DUP:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.dup.x.nxv2f64(double %op2)
62   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.facgt.nxv2f64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op1, <vscale x 2 x double> %[[DUP]])
63   // CHECK: %[[CAST:.*]] = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %[[INTRINSIC]])
64   // CHECK: ret <vscale x 16 x i1> %[[CAST]]
65   return SVE_ACLE_FUNC(svacgt,_n_f64,,)(pg, op1, op2);
66 }
67