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 #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_svcls_s8_z(svbool_t pg,svint8_t op)16 svuint8_t test_svcls_s8_z(svbool_t pg, svint8_t op)
17 {
18 // CHECK-LABEL: test_svcls_s8_z
19 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cls.nxv16i8(<vscale x 16 x i8> zeroinitializer, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
20 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
21 return SVE_ACLE_FUNC(svcls,_s8,_z,)(pg, op);
22 }
23
test_svcls_s16_z(svbool_t pg,svint16_t op)24 svuint16_t test_svcls_s16_z(svbool_t pg, svint16_t op)
25 {
26 // CHECK-LABEL: test_svcls_s16_z
27 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
28 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cls.nxv8i16(<vscale x 8 x i16> zeroinitializer, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
29 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
30 return SVE_ACLE_FUNC(svcls,_s16,_z,)(pg, op);
31 }
32
test_svcls_s32_z(svbool_t pg,svint32_t op)33 svuint32_t test_svcls_s32_z(svbool_t pg, svint32_t op)
34 {
35 // CHECK-LABEL: test_svcls_s32_z
36 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
37 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cls.nxv4i32(<vscale x 4 x i32> zeroinitializer, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
38 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
39 return SVE_ACLE_FUNC(svcls,_s32,_z,)(pg, op);
40 }
41
test_svcls_s64_z(svbool_t pg,svint64_t op)42 svuint64_t test_svcls_s64_z(svbool_t pg, svint64_t op)
43 {
44 // CHECK-LABEL: test_svcls_s64_z
45 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
46 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cls.nxv2i64(<vscale x 2 x i64> zeroinitializer, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
47 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
48 return SVE_ACLE_FUNC(svcls,_s64,_z,)(pg, op);
49 }
50
test_svcls_s8_m(svuint8_t inactive,svbool_t pg,svint8_t op)51 svuint8_t test_svcls_s8_m(svuint8_t inactive, svbool_t pg, svint8_t op)
52 {
53 // CHECK-LABEL: test_svcls_s8_m
54 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cls.nxv16i8(<vscale x 16 x i8> %inactive, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
55 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
56 return SVE_ACLE_FUNC(svcls,_s8,_m,)(inactive, pg, op);
57 }
58
test_svcls_s16_m(svuint16_t inactive,svbool_t pg,svint16_t op)59 svuint16_t test_svcls_s16_m(svuint16_t inactive, svbool_t pg, svint16_t op)
60 {
61 // CHECK-LABEL: test_svcls_s16_m
62 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
63 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cls.nxv8i16(<vscale x 8 x i16> %inactive, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
64 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
65 return SVE_ACLE_FUNC(svcls,_s16,_m,)(inactive, pg, op);
66 }
67
test_svcls_s32_m(svuint32_t inactive,svbool_t pg,svint32_t op)68 svuint32_t test_svcls_s32_m(svuint32_t inactive, svbool_t pg, svint32_t op)
69 {
70 // CHECK-LABEL: test_svcls_s32_m
71 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
72 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cls.nxv4i32(<vscale x 4 x i32> %inactive, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
73 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
74 return SVE_ACLE_FUNC(svcls,_s32,_m,)(inactive, pg, op);
75 }
76
test_svcls_s64_m(svuint64_t inactive,svbool_t pg,svint64_t op)77 svuint64_t test_svcls_s64_m(svuint64_t inactive, svbool_t pg, svint64_t op)
78 {
79 // CHECK-LABEL: test_svcls_s64_m
80 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
81 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cls.nxv2i64(<vscale x 2 x i64> %inactive, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
82 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
83 return SVE_ACLE_FUNC(svcls,_s64,_m,)(inactive, pg, op);
84 }
85
test_svcls_s8_x(svbool_t pg,svint8_t op)86 svuint8_t test_svcls_s8_x(svbool_t pg, svint8_t op)
87 {
88 // CHECK-LABEL: test_svcls_s8_x
89 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cls.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
90 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
91 return SVE_ACLE_FUNC(svcls,_s8,_x,)(pg, op);
92 }
93
test_svcls_s16_x(svbool_t pg,svint16_t op)94 svuint16_t test_svcls_s16_x(svbool_t pg, svint16_t op)
95 {
96 // CHECK-LABEL: test_svcls_s16_x
97 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
98 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cls.nxv8i16(<vscale x 8 x i16> undef, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
99 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
100 return SVE_ACLE_FUNC(svcls,_s16,_x,)(pg, op);
101 }
102
test_svcls_s32_x(svbool_t pg,svint32_t op)103 svuint32_t test_svcls_s32_x(svbool_t pg, svint32_t op)
104 {
105 // CHECK-LABEL: test_svcls_s32_x
106 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
107 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cls.nxv4i32(<vscale x 4 x i32> undef, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
108 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
109 return SVE_ACLE_FUNC(svcls,_s32,_x,)(pg, op);
110 }
111
test_svcls_s64_x(svbool_t pg,svint64_t op)112 svuint64_t test_svcls_s64_x(svbool_t pg, svint64_t op)
113 {
114 // CHECK-LABEL: test_svcls_s64_x
115 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
116 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cls.nxv2i64(<vscale x 2 x i64> undef, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
117 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
118 return SVE_ACLE_FUNC(svcls,_s64,_x,)(pg, op);
119 }
120