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 -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
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null 2>%t
5 // RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
6
7 // If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it.
8 // ASM-NOT: warning
9 #include <arm_sve.h>
10
11 #ifdef SVE_OVERLOADED_FORMS
12 // A simple used,unused... macro, long enough to represent any SVE builtin.
13 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
14 #else
15 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
16 #endif
17
test_svabs_s8_z(svbool_t pg,svint8_t op)18 svint8_t test_svabs_s8_z(svbool_t pg, svint8_t op)
19 {
20 // CHECK-LABEL: test_svabs_s8_z
21 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.abs.nxv16i8(<vscale x 16 x i8> zeroinitializer, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
22 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
23 return SVE_ACLE_FUNC(svabs,_s8,_z,)(pg, op);
24 }
25
test_svabs_s16_z(svbool_t pg,svint16_t op)26 svint16_t test_svabs_s16_z(svbool_t pg, svint16_t op)
27 {
28 // CHECK-LABEL: test_svabs_s16_z
29 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
30 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.abs.nxv8i16(<vscale x 8 x i16> zeroinitializer, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
31 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
32 return SVE_ACLE_FUNC(svabs,_s16,_z,)(pg, op);
33 }
34
test_svabs_s32_z(svbool_t pg,svint32_t op)35 svint32_t test_svabs_s32_z(svbool_t pg, svint32_t op)
36 {
37 // CHECK-LABEL: test_svabs_s32_z
38 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
39 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.abs.nxv4i32(<vscale x 4 x i32> zeroinitializer, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
40 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
41 return SVE_ACLE_FUNC(svabs,_s32,_z,)(pg, op);
42 }
43
test_svabs_s64_z(svbool_t pg,svint64_t op)44 svint64_t test_svabs_s64_z(svbool_t pg, svint64_t op)
45 {
46 // CHECK-LABEL: test_svabs_s64_z
47 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
48 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.abs.nxv2i64(<vscale x 2 x i64> zeroinitializer, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
49 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
50 return SVE_ACLE_FUNC(svabs,_s64,_z,)(pg, op);
51 }
52
test_svabs_s8_m(svint8_t inactive,svbool_t pg,svint8_t op)53 svint8_t test_svabs_s8_m(svint8_t inactive, svbool_t pg, svint8_t op)
54 {
55 // CHECK-LABEL: test_svabs_s8_m
56 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.abs.nxv16i8(<vscale x 16 x i8> %inactive, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
57 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
58 return SVE_ACLE_FUNC(svabs,_s8,_m,)(inactive, pg, op);
59 }
60
test_svabs_s16_m(svint16_t inactive,svbool_t pg,svint16_t op)61 svint16_t test_svabs_s16_m(svint16_t inactive, svbool_t pg, svint16_t op)
62 {
63 // CHECK-LABEL: test_svabs_s16_m
64 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
65 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.abs.nxv8i16(<vscale x 8 x i16> %inactive, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
66 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
67 return SVE_ACLE_FUNC(svabs,_s16,_m,)(inactive, pg, op);
68 }
69
test_svabs_s32_m(svint32_t inactive,svbool_t pg,svint32_t op)70 svint32_t test_svabs_s32_m(svint32_t inactive, svbool_t pg, svint32_t op)
71 {
72 // CHECK-LABEL: test_svabs_s32_m
73 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
74 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.abs.nxv4i32(<vscale x 4 x i32> %inactive, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
75 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
76 return SVE_ACLE_FUNC(svabs,_s32,_m,)(inactive, pg, op);
77 }
78
test_svabs_s64_m(svint64_t inactive,svbool_t pg,svint64_t op)79 svint64_t test_svabs_s64_m(svint64_t inactive, svbool_t pg, svint64_t op)
80 {
81 // CHECK-LABEL: test_svabs_s64_m
82 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
83 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.abs.nxv2i64(<vscale x 2 x i64> %inactive, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
84 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
85 return SVE_ACLE_FUNC(svabs,_s64,_m,)(inactive, pg, op);
86 }
87
test_svabs_s8_x(svbool_t pg,svint8_t op)88 svint8_t test_svabs_s8_x(svbool_t pg, svint8_t op)
89 {
90 // CHECK-LABEL: test_svabs_s8_x
91 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.abs.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i1> %pg, <vscale x 16 x i8> %op)
92 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
93 return SVE_ACLE_FUNC(svabs,_s8,_x,)(pg, op);
94 }
95
test_svabs_s16_x(svbool_t pg,svint16_t op)96 svint16_t test_svabs_s16_x(svbool_t pg, svint16_t op)
97 {
98 // CHECK-LABEL: test_svabs_s16_x
99 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
100 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.abs.nxv8i16(<vscale x 8 x i16> undef, <vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op)
101 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
102 return SVE_ACLE_FUNC(svabs,_s16,_x,)(pg, op);
103 }
104
test_svabs_s32_x(svbool_t pg,svint32_t op)105 svint32_t test_svabs_s32_x(svbool_t pg, svint32_t op)
106 {
107 // CHECK-LABEL: test_svabs_s32_x
108 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
109 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.abs.nxv4i32(<vscale x 4 x i32> undef, <vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op)
110 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
111 return SVE_ACLE_FUNC(svabs,_s32,_x,)(pg, op);
112 }
113
test_svabs_s64_x(svbool_t pg,svint64_t op)114 svint64_t test_svabs_s64_x(svbool_t pg, svint64_t op)
115 {
116 // CHECK-LABEL: test_svabs_s64_x
117 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
118 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.abs.nxv2i64(<vscale x 2 x i64> undef, <vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op)
119 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
120 return SVE_ACLE_FUNC(svabs,_s64,_x,)(pg, op);
121 }
122
test_svabs_f16_z(svbool_t pg,svfloat16_t op)123 svfloat16_t test_svabs_f16_z(svbool_t pg, svfloat16_t op)
124 {
125 // CHECK-LABEL: test_svabs_f16_z
126 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
127 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.fabs.nxv8f16(<vscale x 8 x half> zeroinitializer, <vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op)
128 // CHECK: ret <vscale x 8 x half> %[[INTRINSIC]]
129 return SVE_ACLE_FUNC(svabs,_f16,_z,)(pg, op);
130 }
131
test_svabs_f32_z(svbool_t pg,svfloat32_t op)132 svfloat32_t test_svabs_f32_z(svbool_t pg, svfloat32_t op)
133 {
134 // CHECK-LABEL: test_svabs_f32_z
135 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
136 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fabs.nxv4f32(<vscale x 4 x float> zeroinitializer, <vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op)
137 // CHECK: ret <vscale x 4 x float> %[[INTRINSIC]]
138 return SVE_ACLE_FUNC(svabs,_f32,_z,)(pg, op);
139 }
140
test_svabs_f64_z(svbool_t pg,svfloat64_t op)141 svfloat64_t test_svabs_f64_z(svbool_t pg, svfloat64_t op)
142 {
143 // CHECK-LABEL: test_svabs_f64_z
144 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
145 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.fabs.nxv2f64(<vscale x 2 x double> zeroinitializer, <vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op)
146 // CHECK: ret <vscale x 2 x double> %[[INTRINSIC]]
147 return SVE_ACLE_FUNC(svabs,_f64,_z,)(pg, op);
148 }
149
test_svabs_f16_m(svfloat16_t inactive,svbool_t pg,svfloat16_t op)150 svfloat16_t test_svabs_f16_m(svfloat16_t inactive, svbool_t pg, svfloat16_t op)
151 {
152 // CHECK-LABEL: test_svabs_f16_m
153 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
154 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.fabs.nxv8f16(<vscale x 8 x half> %inactive, <vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op)
155 // CHECK: ret <vscale x 8 x half> %[[INTRINSIC]]
156 return SVE_ACLE_FUNC(svabs,_f16,_m,)(inactive, pg, op);
157 }
158
test_svabs_f32_m(svfloat32_t inactive,svbool_t pg,svfloat32_t op)159 svfloat32_t test_svabs_f32_m(svfloat32_t inactive, svbool_t pg, svfloat32_t op)
160 {
161 // CHECK-LABEL: test_svabs_f32_m
162 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
163 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fabs.nxv4f32(<vscale x 4 x float> %inactive, <vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op)
164 // CHECK: ret <vscale x 4 x float> %[[INTRINSIC]]
165 return SVE_ACLE_FUNC(svabs,_f32,_m,)(inactive, pg, op);
166 }
167
test_svabs_f64_m(svfloat64_t inactive,svbool_t pg,svfloat64_t op)168 svfloat64_t test_svabs_f64_m(svfloat64_t inactive, svbool_t pg, svfloat64_t op)
169 {
170 // CHECK-LABEL: test_svabs_f64_m
171 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
172 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.fabs.nxv2f64(<vscale x 2 x double> %inactive, <vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op)
173 // CHECK: ret <vscale x 2 x double> %[[INTRINSIC]]
174 return SVE_ACLE_FUNC(svabs,_f64,_m,)(inactive, pg, op);
175 }
176
test_svabs_f16_x(svbool_t pg,svfloat16_t op)177 svfloat16_t test_svabs_f16_x(svbool_t pg, svfloat16_t op)
178 {
179 // CHECK-LABEL: test_svabs_f16_x
180 // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
181 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.fabs.nxv8f16(<vscale x 8 x half> undef, <vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op)
182 // CHECK: ret <vscale x 8 x half> %[[INTRINSIC]]
183 return SVE_ACLE_FUNC(svabs,_f16,_x,)(pg, op);
184 }
185
test_svabs_f32_x(svbool_t pg,svfloat32_t op)186 svfloat32_t test_svabs_f32_x(svbool_t pg, svfloat32_t op)
187 {
188 // CHECK-LABEL: test_svabs_f32_x
189 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
190 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.fabs.nxv4f32(<vscale x 4 x float> undef, <vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op)
191 // CHECK: ret <vscale x 4 x float> %[[INTRINSIC]]
192 return SVE_ACLE_FUNC(svabs,_f32,_x,)(pg, op);
193 }
194
test_svabs_f64_x(svbool_t pg,svfloat64_t op)195 svfloat64_t test_svabs_f64_x(svbool_t pg, svfloat64_t op)
196 {
197 // CHECK-LABEL: test_svabs_f64_x
198 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
199 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.fabs.nxv2f64(<vscale x 2 x double> undef, <vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op)
200 // CHECK: ret <vscale x 2 x double> %[[INTRINSIC]]
201 return SVE_ACLE_FUNC(svabs,_f64,_x,)(pg, op);
202 }
203