1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple -asm-verbose=false -mcpu=cyclone | FileCheck %s
3 define signext i8 @test_vaddv_s8(<8 x i8> %a1) {
4 ; CHECK-LABEL: test_vaddv_s8:
5 ; CHECK: addv.8b b[[REGNUM:[0-9]+]], v0
6 ; CHECK-NEXT: smov.b w0, v[[REGNUM]][0]
9 %vaddv.i = tail call i32 @llvm.aarch64.neon.saddv.i32.v8i8(<8 x i8> %a1)
10 %0 = trunc i32 %vaddv.i to i8
14 define <8 x i8> @test_vaddv_s8_used_by_laneop(<8 x i8> %a1, <8 x i8> %a2) {
15 ; CHECK-LABEL: test_vaddv_s8_used_by_laneop:
16 ; CHECK: addv.8b b[[REGNUM:[0-9]+]], v1
17 ; CHECK-NEXT: mov.b v0[3], v[[REGNUM]][0]
20 %0 = tail call i32 @llvm.aarch64.neon.saddv.i32.v8i8(<8 x i8> %a2)
21 %1 = trunc i32 %0 to i8
22 %2 = insertelement <8 x i8> %a1, i8 %1, i32 3
26 define signext i16 @test_vaddv_s16(<4 x i16> %a1) {
27 ; CHECK-LABEL: test_vaddv_s16:
28 ; CHECK: addv.4h h[[REGNUM:[0-9]+]], v0
29 ; CHECK-NEXT: smov.h w0, v[[REGNUM]][0]
32 %vaddv.i = tail call i32 @llvm.aarch64.neon.saddv.i32.v4i16(<4 x i16> %a1)
33 %0 = trunc i32 %vaddv.i to i16
37 define <4 x i16> @test_vaddv_s16_used_by_laneop(<4 x i16> %a1, <4 x i16> %a2) {
38 ; CHECK-LABEL: test_vaddv_s16_used_by_laneop:
39 ; CHECK: addv.4h h[[REGNUM:[0-9]+]], v1
40 ; CHECK-NEXT: mov.h v0[3], v[[REGNUM]][0]
43 %0 = tail call i32 @llvm.aarch64.neon.saddv.i32.v4i16(<4 x i16> %a2)
44 %1 = trunc i32 %0 to i16
45 %2 = insertelement <4 x i16> %a1, i16 %1, i32 3
49 define i32 @test_vaddv_s32(<2 x i32> %a1) {
50 ; CHECK-LABEL: test_vaddv_s32:
51 ; 2 x i32 is not supported by the ISA, thus, this is a special case
52 ; CHECK: addp.2s v[[REGNUM:[0-9]+]], v0, v0
53 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
56 %vaddv.i = tail call i32 @llvm.aarch64.neon.saddv.i32.v2i32(<2 x i32> %a1)
60 define <2 x i32> @test_vaddv_s32_used_by_laneop(<2 x i32> %a1, <2 x i32> %a2) {
61 ; CHECK-LABEL: test_vaddv_s32_used_by_laneop:
62 ; CHECK: addp.2s v[[REGNUM:[0-9]+]], v1, v1
63 ; CHECK-NEXT: mov.s v0[1], v[[REGNUM]][0]
66 %0 = tail call i32 @llvm.aarch64.neon.saddv.i32.v2i32(<2 x i32> %a2)
67 %1 = insertelement <2 x i32> %a1, i32 %0, i32 1
71 define i64 @test_vaddv_s64(<2 x i64> %a1) {
72 ; CHECK-LABEL: test_vaddv_s64:
73 ; CHECK: addp.2d [[REGNUM:d[0-9]+]], v0
74 ; CHECK-NEXT: fmov x0, [[REGNUM]]
77 %vaddv.i = tail call i64 @llvm.aarch64.neon.saddv.i64.v2i64(<2 x i64> %a1)
81 define <2 x i64> @test_vaddv_s64_used_by_laneop(<2 x i64> %a1, <2 x i64> %a2) {
82 ; CHECK-LABEL: test_vaddv_s64_used_by_laneop:
83 ; CHECK: addp.2d d[[REGNUM:[0-9]+]], v1
84 ; CHECK-NEXT: mov.d v0[1], v[[REGNUM]][0]
87 %0 = tail call i64 @llvm.aarch64.neon.saddv.i64.v2i64(<2 x i64> %a2)
88 %1 = insertelement <2 x i64> %a1, i64 %0, i64 1
92 define zeroext i8 @test_vaddv_u8(<8 x i8> %a1) {
93 ; CHECK-LABEL: test_vaddv_u8:
94 ; CHECK: addv.8b b[[REGNUM:[0-9]+]], v0
95 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
98 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v8i8(<8 x i8> %a1)
99 %0 = trunc i32 %vaddv.i to i8
103 define <8 x i8> @test_vaddv_u8_used_by_laneop(<8 x i8> %a1, <8 x i8> %a2) {
104 ; CHECK-LABEL: test_vaddv_u8_used_by_laneop:
105 ; CHECK: addv.8b b[[REGNUM:[0-9]+]], v1
106 ; CHECK-NEXT: mov.b v0[3], v[[REGNUM]][0]
109 %0 = tail call i32 @llvm.aarch64.neon.uaddv.i32.v8i8(<8 x i8> %a2)
110 %1 = trunc i32 %0 to i8
111 %2 = insertelement <8 x i8> %a1, i8 %1, i32 3
115 define i32 @test_vaddv_u8_masked(<8 x i8> %a1) {
116 ; CHECK-LABEL: test_vaddv_u8_masked:
117 ; CHECK: addv.8b b[[REGNUM:[0-9]+]], v0
118 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
121 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v8i8(<8 x i8> %a1)
122 %0 = and i32 %vaddv.i, 511 ; 0x1ff
126 define zeroext i16 @test_vaddv_u16(<4 x i16> %a1) {
127 ; CHECK-LABEL: test_vaddv_u16:
128 ; CHECK: addv.4h h[[REGNUM:[0-9]+]], v0
129 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
132 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v4i16(<4 x i16> %a1)
133 %0 = trunc i32 %vaddv.i to i16
137 define <4 x i16> @test_vaddv_u16_used_by_laneop(<4 x i16> %a1, <4 x i16> %a2) {
138 ; CHECK-LABEL: test_vaddv_u16_used_by_laneop:
139 ; CHECK: addv.4h h[[REGNUM:[0-9]+]], v1
140 ; CHECK-NEXT: mov.h v0[3], v[[REGNUM]][0]
143 %0 = tail call i32 @llvm.aarch64.neon.uaddv.i32.v4i16(<4 x i16> %a2)
144 %1 = trunc i32 %0 to i16
145 %2 = insertelement <4 x i16> %a1, i16 %1, i32 3
149 define i32 @test_vaddv_u16_masked(<4 x i16> %a1) {
150 ; CHECK-LABEL: test_vaddv_u16_masked:
151 ; CHECK: addv.4h h[[REGNUM:[0-9]+]], v0
152 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
155 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v4i16(<4 x i16> %a1)
156 %0 = and i32 %vaddv.i, 3276799 ; 0x31ffff
160 define i32 @test_vaddv_u32(<2 x i32> %a1) {
161 ; CHECK-LABEL: test_vaddv_u32:
162 ; 2 x i32 is not supported by the ISA, thus, this is a special case
163 ; CHECK: addp.2s v[[REGNUM:[0-9]+]], v0, v0
164 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
167 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v2i32(<2 x i32> %a1)
171 define <2 x i32> @test_vaddv_u32_used_by_laneop(<2 x i32> %a1, <2 x i32> %a2) {
172 ; CHECK-LABEL: test_vaddv_u32_used_by_laneop:
173 ; CHECK: addp.2s v[[REGNUM:[0-9]+]], v1, v1
174 ; CHECK-NEXT: mov.s v0[1], v[[REGNUM]][0]
177 %0 = tail call i32 @llvm.aarch64.neon.uaddv.i32.v2i32(<2 x i32> %a2)
178 %1 = insertelement <2 x i32> %a1, i32 %0, i32 1
182 define float @test_vaddv_f32(<2 x float> %a1) {
183 ; CHECK-LABEL: test_vaddv_f32:
184 ; CHECK: faddp.2s s0, v0
187 %vaddv.i = tail call float @llvm.aarch64.neon.faddv.f32.v2f32(<2 x float> %a1)
191 define float @test_vaddv_v4f32(<4 x float> %a1) {
192 ; CHECK-LABEL: test_vaddv_v4f32:
193 ; CHECK: faddp.4s [[REGNUM:v[0-9]+]], v0, v0
194 ; CHECK: faddp.2s s0, [[REGNUM]]
197 %vaddv.i = tail call float @llvm.aarch64.neon.faddv.f32.v4f32(<4 x float> %a1)
201 define double @test_vaddv_f64(<2 x double> %a1) {
202 ; CHECK-LABEL: test_vaddv_f64:
203 ; CHECK: faddp.2d d0, v0
206 %vaddv.i = tail call double @llvm.aarch64.neon.faddv.f64.v2f64(<2 x double> %a1)
210 define i64 @test_vaddv_u64(<2 x i64> %a1) {
211 ; CHECK-LABEL: test_vaddv_u64:
212 ; CHECK: addp.2d [[REGNUM:d[0-9]+]], v0
213 ; CHECK-NEXT: fmov x0, [[REGNUM]]
216 %vaddv.i = tail call i64 @llvm.aarch64.neon.uaddv.i64.v2i64(<2 x i64> %a1)
220 define <2 x i64> @test_vaddv_u64_used_by_laneop(<2 x i64> %a1, <2 x i64> %a2) {
221 ; CHECK-LABEL: test_vaddv_u64_used_by_laneop:
222 ; CHECK: addp.2d d[[REGNUM:[0-9]+]], v1
223 ; CHECK-NEXT: mov.d v0[1], v[[REGNUM]][0]
226 %0 = tail call i64 @llvm.aarch64.neon.uaddv.i64.v2i64(<2 x i64> %a2)
227 %1 = insertelement <2 x i64> %a1, i64 %0, i64 1
231 define <1 x i64> @test_vaddv_u64_to_vec(<2 x i64> %a1) {
232 ; CHECK-LABEL: test_vaddv_u64_to_vec:
233 ; CHECK: addp.2d d0, v0
238 %vaddv.i = tail call i64 @llvm.aarch64.neon.uaddv.i64.v2i64(<2 x i64> %a1)
239 %vec = insertelement <1 x i64> undef, i64 %vaddv.i, i32 0
243 define signext i8 @test_vaddvq_s8(<16 x i8> %a1) {
244 ; CHECK-LABEL: test_vaddvq_s8:
245 ; CHECK: addv.16b b[[REGNUM:[0-9]+]], v0
246 ; CHECK-NEXT: smov.b w0, v[[REGNUM]][0]
249 %vaddv.i = tail call i32 @llvm.aarch64.neon.saddv.i32.v16i8(<16 x i8> %a1)
250 %0 = trunc i32 %vaddv.i to i8
254 define <16 x i8> @test_vaddvq_s8_used_by_laneop(<16 x i8> %a1, <16 x i8> %a2) {
255 ; CHECK-LABEL: test_vaddvq_s8_used_by_laneop:
256 ; CHECK: addv.16b b[[REGNUM:[0-9]+]], v1
257 ; CHECK-NEXT: mov.b v0[3], v[[REGNUM]][0]
260 %0 = tail call i32 @llvm.aarch64.neon.saddv.i32.v16i8(<16 x i8> %a2)
261 %1 = trunc i32 %0 to i8
262 %2 = insertelement <16 x i8> %a1, i8 %1, i32 3
266 define signext i16 @test_vaddvq_s16(<8 x i16> %a1) {
267 ; CHECK-LABEL: test_vaddvq_s16:
268 ; CHECK: addv.8h h[[REGNUM:[0-9]+]], v0
269 ; CHECK-NEXT: smov.h w0, v[[REGNUM]][0]
272 %vaddv.i = tail call i32 @llvm.aarch64.neon.saddv.i32.v8i16(<8 x i16> %a1)
273 %0 = trunc i32 %vaddv.i to i16
277 define <8 x i16> @test_vaddvq_s16_used_by_laneop(<8 x i16> %a1, <8 x i16> %a2) {
278 ; CHECK-LABEL: test_vaddvq_s16_used_by_laneop:
279 ; CHECK: addv.8h h[[REGNUM:[0-9]+]], v1
280 ; CHECK-NEXT: mov.h v0[3], v[[REGNUM]][0]
283 %0 = tail call i32 @llvm.aarch64.neon.saddv.i32.v8i16(<8 x i16> %a2)
284 %1 = trunc i32 %0 to i16
285 %2 = insertelement <8 x i16> %a1, i16 %1, i32 3
289 define i32 @test_vaddvq_s32(<4 x i32> %a1) {
290 ; CHECK-LABEL: test_vaddvq_s32:
291 ; CHECK: addv.4s [[REGNUM:s[0-9]+]], v0
292 ; CHECK-NEXT: fmov w0, [[REGNUM]]
295 %vaddv.i = tail call i32 @llvm.aarch64.neon.saddv.i32.v4i32(<4 x i32> %a1)
299 define <4 x i32> @test_vaddvq_s32_used_by_laneop(<4 x i32> %a1, <4 x i32> %a2) {
300 ; CHECK-LABEL: test_vaddvq_s32_used_by_laneop:
301 ; CHECK: addv.4s s[[REGNUM:[0-9]+]], v1
302 ; CHECK-NEXT: mov.s v0[3], v[[REGNUM]][0]
305 %0 = tail call i32 @llvm.aarch64.neon.saddv.i32.v4i32(<4 x i32> %a2)
306 %1 = insertelement <4 x i32> %a1, i32 %0, i32 3
310 define zeroext i8 @test_vaddvq_u8(<16 x i8> %a1) {
311 ; CHECK-LABEL: test_vaddvq_u8:
312 ; CHECK: addv.16b b[[REGNUM:[0-9]+]], v0
313 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
316 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v16i8(<16 x i8> %a1)
317 %0 = trunc i32 %vaddv.i to i8
321 define <16 x i8> @test_vaddvq_u8_used_by_laneop(<16 x i8> %a1, <16 x i8> %a2) {
322 ; CHECK-LABEL: test_vaddvq_u8_used_by_laneop:
323 ; CHECK: addv.16b b[[REGNUM:[0-9]+]], v1
324 ; CHECK-NEXT: mov.b v0[3], v[[REGNUM]][0]
327 %0 = tail call i32 @llvm.aarch64.neon.uaddv.i32.v16i8(<16 x i8> %a2)
328 %1 = trunc i32 %0 to i8
329 %2 = insertelement <16 x i8> %a1, i8 %1, i32 3
333 define zeroext i16 @test_vaddvq_u16(<8 x i16> %a1) {
334 ; CHECK-LABEL: test_vaddvq_u16:
335 ; CHECK: addv.8h h[[REGNUM:[0-9]+]], v0
336 ; CHECK-NEXT: fmov w0, s[[REGNUM]]
339 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v8i16(<8 x i16> %a1)
340 %0 = trunc i32 %vaddv.i to i16
344 define <8 x i16> @test_vaddvq_u16_used_by_laneop(<8 x i16> %a1, <8 x i16> %a2) {
345 ; CHECK-LABEL: test_vaddvq_u16_used_by_laneop:
346 ; CHECK: addv.8h h[[REGNUM:[0-9]+]], v1
347 ; CHECK-NEXT: mov.h v0[3], v[[REGNUM]][0]
350 %0 = tail call i32 @llvm.aarch64.neon.uaddv.i32.v8i16(<8 x i16> %a2)
351 %1 = trunc i32 %0 to i16
352 %2 = insertelement <8 x i16> %a1, i16 %1, i32 3
356 define i32 @test_vaddvq_u32(<4 x i32> %a1) {
357 ; CHECK-LABEL: test_vaddvq_u32:
358 ; CHECK: addv.4s [[REGNUM:s[0-9]+]], v0
359 ; CHECK-NEXT: fmov [[FMOVRES:w[0-9]+]], [[REGNUM]]
362 %vaddv.i = tail call i32 @llvm.aarch64.neon.uaddv.i32.v4i32(<4 x i32> %a1)
366 define <4 x i32> @test_vaddvq_u32_used_by_laneop(<4 x i32> %a1, <4 x i32> %a2) {
367 ; CHECK-LABEL: test_vaddvq_u32_used_by_laneop:
368 ; CHECK: addv.4s s[[REGNUM:[0-9]+]], v1
369 ; CHECK-NEXT: mov.s v0[3], v[[REGNUM]][0]
372 %0 = tail call i32 @llvm.aarch64.neon.uaddv.i32.v4i32(<4 x i32> %a2)
373 %1 = insertelement <4 x i32> %a1, i32 %0, i32 3
377 declare i32 @llvm.aarch64.neon.uaddv.i32.v4i32(<4 x i32>)
379 declare i32 @llvm.aarch64.neon.uaddv.i32.v8i16(<8 x i16>)
381 declare i32 @llvm.aarch64.neon.uaddv.i32.v16i8(<16 x i8>)
383 declare i32 @llvm.aarch64.neon.saddv.i32.v4i32(<4 x i32>)
385 declare i32 @llvm.aarch64.neon.saddv.i32.v8i16(<8 x i16>)
387 declare i32 @llvm.aarch64.neon.saddv.i32.v16i8(<16 x i8>)
389 declare i64 @llvm.aarch64.neon.uaddv.i64.v2i64(<2 x i64>)
391 declare i32 @llvm.aarch64.neon.uaddv.i32.v2i32(<2 x i32>)
393 declare i32 @llvm.aarch64.neon.uaddv.i32.v4i16(<4 x i16>)
395 declare i32 @llvm.aarch64.neon.uaddv.i32.v8i8(<8 x i8>)
397 declare i32 @llvm.aarch64.neon.saddv.i32.v2i32(<2 x i32>)
399 declare i64 @llvm.aarch64.neon.saddv.i64.v2i64(<2 x i64>)
401 declare i32 @llvm.aarch64.neon.saddv.i32.v4i16(<4 x i16>)
403 declare i32 @llvm.aarch64.neon.saddv.i32.v8i8(<8 x i8>)
405 declare float @llvm.aarch64.neon.faddv.f32.v2f32(<2 x float> %a1)
406 declare float @llvm.aarch64.neon.faddv.f32.v4f32(<4 x float> %a1)
407 declare double @llvm.aarch64.neon.faddv.f64.v2f64(<2 x double> %a1)