1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple | FileCheck %s
4 define <8 x i8> @vzipi8(<8 x i8>* %A, <8 x i8>* %B) nounwind {
7 ; CHECK-NEXT: ldr d0, [x0]
8 ; CHECK-NEXT: ldr d1, [x1]
9 ; CHECK-NEXT: zip1.8b v2, v0, v1
10 ; CHECK-NEXT: zip2.8b v0, v0, v1
11 ; CHECK-NEXT: add.8b v0, v2, v0
13 %tmp1 = load <8 x i8>, <8 x i8>* %A
14 %tmp2 = load <8 x i8>, <8 x i8>* %B
15 %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
16 %tmp4 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
17 %tmp5 = add <8 x i8> %tmp3, %tmp4
21 define <4 x i16> @vzipi16(<4 x i16>* %A, <4 x i16>* %B) nounwind {
22 ; CHECK-LABEL: vzipi16:
24 ; CHECK-NEXT: ldr d0, [x0]
25 ; CHECK-NEXT: ldr d1, [x1]
26 ; CHECK-NEXT: zip1.4h v2, v0, v1
27 ; CHECK-NEXT: zip2.4h v0, v0, v1
28 ; CHECK-NEXT: add.4h v0, v2, v0
30 %tmp1 = load <4 x i16>, <4 x i16>* %A
31 %tmp2 = load <4 x i16>, <4 x i16>* %B
32 %tmp3 = shufflevector <4 x i16> %tmp1, <4 x i16> %tmp2, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
33 %tmp4 = shufflevector <4 x i16> %tmp1, <4 x i16> %tmp2, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
34 %tmp5 = add <4 x i16> %tmp3, %tmp4
38 define <16 x i8> @vzipQi8(<16 x i8>* %A, <16 x i8>* %B) nounwind {
39 ; CHECK-LABEL: vzipQi8:
41 ; CHECK-NEXT: ldr q0, [x0]
42 ; CHECK-NEXT: ldr q1, [x1]
43 ; CHECK-NEXT: zip1.16b v2, v0, v1
44 ; CHECK-NEXT: zip2.16b v0, v0, v1
45 ; CHECK-NEXT: add.16b v0, v2, v0
47 %tmp1 = load <16 x i8>, <16 x i8>* %A
48 %tmp2 = load <16 x i8>, <16 x i8>* %B
49 %tmp3 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23>
50 %tmp4 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
51 %tmp5 = add <16 x i8> %tmp3, %tmp4
55 define <8 x i16> @vzipQi16(<8 x i16>* %A, <8 x i16>* %B) nounwind {
56 ; CHECK-LABEL: vzipQi16:
58 ; CHECK-NEXT: ldr q0, [x0]
59 ; CHECK-NEXT: ldr q1, [x1]
60 ; CHECK-NEXT: zip1.8h v2, v0, v1
61 ; CHECK-NEXT: zip2.8h v0, v0, v1
62 ; CHECK-NEXT: add.8h v0, v2, v0
64 %tmp1 = load <8 x i16>, <8 x i16>* %A
65 %tmp2 = load <8 x i16>, <8 x i16>* %B
66 %tmp3 = shufflevector <8 x i16> %tmp1, <8 x i16> %tmp2, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
67 %tmp4 = shufflevector <8 x i16> %tmp1, <8 x i16> %tmp2, <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
68 %tmp5 = add <8 x i16> %tmp3, %tmp4
72 define <4 x i32> @vzipQi32(<4 x i32>* %A, <4 x i32>* %B) nounwind {
73 ; CHECK-LABEL: vzipQi32:
75 ; CHECK-NEXT: ldr q0, [x0]
76 ; CHECK-NEXT: ldr q1, [x1]
77 ; CHECK-NEXT: zip1.4s v2, v0, v1
78 ; CHECK-NEXT: zip2.4s v0, v0, v1
79 ; CHECK-NEXT: add.4s v0, v2, v0
81 %tmp1 = load <4 x i32>, <4 x i32>* %A
82 %tmp2 = load <4 x i32>, <4 x i32>* %B
83 %tmp3 = shufflevector <4 x i32> %tmp1, <4 x i32> %tmp2, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
84 %tmp4 = shufflevector <4 x i32> %tmp1, <4 x i32> %tmp2, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
85 %tmp5 = add <4 x i32> %tmp3, %tmp4
89 define <4 x float> @vzipQf(<4 x float>* %A, <4 x float>* %B) nounwind {
90 ; CHECK-LABEL: vzipQf:
92 ; CHECK-NEXT: ldr q0, [x0]
93 ; CHECK-NEXT: ldr q1, [x1]
94 ; CHECK-NEXT: zip1.4s v2, v0, v1
95 ; CHECK-NEXT: zip2.4s v0, v0, v1
96 ; CHECK-NEXT: fadd.4s v0, v2, v0
98 %tmp1 = load <4 x float>, <4 x float>* %A
99 %tmp2 = load <4 x float>, <4 x float>* %B
100 %tmp3 = shufflevector <4 x float> %tmp1, <4 x float> %tmp2, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
101 %tmp4 = shufflevector <4 x float> %tmp1, <4 x float> %tmp2, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
102 %tmp5 = fadd <4 x float> %tmp3, %tmp4
103 ret <4 x float> %tmp5
106 ; Undef shuffle indices should not prevent matching to VZIP:
108 define <8 x i8> @vzipi8_undef(<8 x i8>* %A, <8 x i8>* %B) nounwind {
109 ; CHECK-LABEL: vzipi8_undef:
111 ; CHECK-NEXT: ldr d0, [x0]
112 ; CHECK-NEXT: ldr d1, [x1]
113 ; CHECK-NEXT: zip1.8b v2, v0, v1
114 ; CHECK-NEXT: zip2.8b v0, v0, v1
115 ; CHECK-NEXT: add.8b v0, v2, v0
117 %tmp1 = load <8 x i8>, <8 x i8>* %A
118 %tmp2 = load <8 x i8>, <8 x i8>* %B
119 %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 0, i32 undef, i32 1, i32 9, i32 undef, i32 10, i32 3, i32 11>
120 %tmp4 = shufflevector <8 x i8> %tmp1, <8 x i8> %tmp2, <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 undef, i32 undef, i32 15>
121 %tmp5 = add <8 x i8> %tmp3, %tmp4
125 define <16 x i8> @vzipQi8_undef(<16 x i8>* %A, <16 x i8>* %B) nounwind {
126 ; CHECK-LABEL: vzipQi8_undef:
128 ; CHECK-NEXT: ldr q0, [x0]
129 ; CHECK-NEXT: ldr q1, [x1]
130 ; CHECK-NEXT: zip1.16b v2, v0, v1
131 ; CHECK-NEXT: zip2.16b v0, v0, v1
132 ; CHECK-NEXT: add.16b v0, v2, v0
134 %tmp1 = load <16 x i8>, <16 x i8>* %A
135 %tmp2 = load <16 x i8>, <16 x i8>* %B
136 %tmp3 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 0, i32 16, i32 1, i32 undef, i32 undef, i32 undef, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23>
137 %tmp4 = shufflevector <16 x i8> %tmp1, <16 x i8> %tmp2, <16 x i32> <i32 8, i32 24, i32 9, i32 undef, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 undef, i32 14, i32 30, i32 undef, i32 31>
138 %tmp5 = add <16 x i8> %tmp3, %tmp4
142 define <16 x i8> @combine_v16i8(<8 x i8> %0, <8 x i8> %1) {
143 ; CHECK-LABEL: combine_v16i8:
145 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
146 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
147 ; CHECK-NEXT: zip1.16b v0, v0, v1
149 %3 = shufflevector <8 x i8> %0, <8 x i8> %1, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
153 define <16 x i8> @combine2_v16i8(<8 x i8> %0, <8 x i8> %1) {
154 ; CHECK-LABEL: combine2_v16i8:
156 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
157 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
158 ; CHECK-NEXT: zip1.16b v0, v0, v1
160 %3 = shufflevector <8 x i8> %0, <8 x i8> %1, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
161 %4 = shufflevector <8 x i8> %0, <8 x i8> %1, <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
162 %5 = shufflevector <8 x i8> %3, <8 x i8> %4, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
166 define <8 x i16> @combine_v8i16(<4 x i16> %0, <4 x i16> %1) {
167 ; CHECK-LABEL: combine_v8i16:
169 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
170 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
171 ; CHECK-NEXT: zip1.8h v0, v0, v1
173 %3 = shufflevector <4 x i16> %0, <4 x i16> %1, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
177 define <8 x i16> @combine2_v8i16(<4 x i16> %0, <4 x i16> %1) {
178 ; CHECK-LABEL: combine2_v8i16:
180 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
181 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
182 ; CHECK-NEXT: zip1.8h v0, v0, v1
184 %3 = shufflevector <4 x i16> %0, <4 x i16> %1, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
185 %4 = shufflevector <4 x i16> %0, <4 x i16> %1, <4 x i32> <i32 2, i32 6, i32 3, i32 7>
186 %5 = shufflevector <4 x i16> %3, <4 x i16> %4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
190 define <4 x i32> @combine_v4i32(<2 x i32> %0, <2 x i32> %1) {
191 ; CHECK-LABEL: combine_v4i32:
193 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
194 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
195 ; CHECK-NEXT: zip1.4s v0, v0, v1
197 %3 = shufflevector <2 x i32> %0, <2 x i32> %1, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
201 define <4 x i32> @combine2_v4i32(<2 x i32> %0, <2 x i32> %1) {
202 ; CHECK-LABEL: combine2_v4i32:
204 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
205 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
206 ; CHECK-NEXT: zip1.4s v0, v0, v1
208 %3 = shufflevector <2 x i32> %0, <2 x i32> %1, <2 x i32> <i32 0, i32 2>
209 %4 = shufflevector <2 x i32> %0, <2 x i32> %1, <2 x i32> <i32 1, i32 3>
210 %5 = shufflevector <2 x i32> %3, <2 x i32> %4, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
214 define <16 x i8> @combine_v16i8_undef(<8 x i8> %0, <8 x i8> %1) {
215 ; CHECK-LABEL: combine_v16i8_undef:
217 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
218 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
219 ; CHECK-NEXT: zip1.16b v0, v0, v1
221 %3 = shufflevector <8 x i8> %0, <8 x i8> %1, <16 x i32> <i32 0, i32 undef, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
225 define <16 x i8> @combine2_v16i8_undef(<8 x i8> %0, <8 x i8> %1) {
226 ; CHECK-LABEL: combine2_v16i8_undef:
228 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
229 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
230 ; CHECK-NEXT: zip1.16b v0, v0, v1
232 %3 = shufflevector <8 x i8> %0, <8 x i8> %1, <8 x i32> <i32 0, i32 undef, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11>
233 %4 = shufflevector <8 x i8> %0, <8 x i8> %1, <8 x i32> <i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
234 %5 = shufflevector <8 x i8> %3, <8 x i8> %4, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
238 define <8 x i16> @combine_v8i16_undef(<4 x i16> %0, <4 x i16> %1) {
239 ; CHECK-LABEL: combine_v8i16_undef:
241 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
242 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
243 ; CHECK-NEXT: zip1.8h v0, v0, v1
245 %3 = shufflevector <4 x i16> %0, <4 x i16> %1, <8 x i32> <i32 0, i32 undef, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
249 ; FIXME: This could be zip1 too, 8,0,9,1... pattern is handled
250 define <16 x i8> @combine_v8i16_8first(<8 x i8> %0, <8 x i8> %1) {
251 ; CHECK-LABEL: combine_v8i16_8first:
253 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1_q2
254 ; CHECK-NEXT: adrp x8, .LCPI17_0
255 ; CHECK-NEXT: fmov d2, d0
256 ; CHECK-NEXT: ldr q3, [x8, :lo12:.LCPI17_0]
257 ; CHECK-NEXT: tbl.16b v0, { v1, v2 }, v3
259 %3 = shufflevector <8 x i8> %1, <8 x i8> %0, <16 x i32> <i32 8, i32 0, i32 9, i32 1, i32 10, i32 2, i32 11, i32 3, i32 12, i32 4, i32 13, i32 5, i32 14, i32 6, i32 15, i32 7>
264 ; FIXME: This could be zip1 too, 8,0,9,1... pattern is handled
265 define <16 x i8> @combine_v8i16_8firstundef(<8 x i8> %0, <8 x i8> %1) {
266 ; CHECK-LABEL: combine_v8i16_8firstundef:
268 ; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1_q2
269 ; CHECK-NEXT: adrp x8, .LCPI18_0
270 ; CHECK-NEXT: fmov d2, d0
271 ; CHECK-NEXT: ldr q3, [x8, :lo12:.LCPI18_0]
272 ; CHECK-NEXT: tbl.16b v0, { v1, v2 }, v3
274 %3 = shufflevector <8 x i8> %1, <8 x i8> %0, <16 x i32> <i32 8, i32 0, i32 9, i32 1, i32 10, i32 2, i32 11, i32 3, i32 12, i32 4, i32 13, i32 5, i32 14, i32 6, i32 15, i32 undef>
278 define <4 x float> @shuffle_zip1(<4 x float> %arg) {
279 ; CHECK-LABEL: shuffle_zip1:
280 ; CHECK: // %bb.0: // %bb
281 ; CHECK-NEXT: movi.2d v1, #0000000000000000
282 ; CHECK-NEXT: fcmgt.4s v0, v0, v1
283 ; CHECK-NEXT: uzp1.8h v1, v0, v0
284 ; CHECK-NEXT: xtn.4h v0, v0
285 ; CHECK-NEXT: xtn.4h v1, v1
286 ; CHECK-NEXT: zip2.4h v0, v0, v1
287 ; CHECK-NEXT: fmov.4s v1, #1.00000000
288 ; CHECK-NEXT: zip1.4h v0, v0, v0
289 ; CHECK-NEXT: sshll.4s v0, v0, #0
290 ; CHECK-NEXT: and.16b v0, v1, v0
293 %inst = fcmp olt <4 x float> zeroinitializer, %arg
294 %inst1 = shufflevector <4 x i1> %inst, <4 x i1> zeroinitializer, <2 x i32> <i32 2, i32 0>
295 %inst2 = shufflevector <2 x i1> %inst1, <2 x i1> zeroinitializer, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
296 %inst3 = select <4 x i1> %inst2, <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, <4 x float> zeroinitializer
297 ret <4 x float> %inst3
300 define <4 x i32> @shuffle_zip2(<4 x i32> %arg) {
301 ; CHECK-LABEL: shuffle_zip2:
302 ; CHECK: // %bb.0: // %bb
303 ; CHECK-NEXT: cmtst.4s v0, v0, v0
304 ; CHECK-NEXT: uzp1.8h v1, v0, v0
305 ; CHECK-NEXT: xtn.4h v0, v0
306 ; CHECK-NEXT: xtn.4h v1, v1
307 ; CHECK-NEXT: zip2.4h v0, v0, v1
308 ; CHECK-NEXT: movi.4s v1, #1
309 ; CHECK-NEXT: zip1.4h v0, v0, v0
310 ; CHECK-NEXT: ushll.4s v0, v0, #0
311 ; CHECK-NEXT: and.16b v0, v0, v1
314 %inst = icmp ult <4 x i32> zeroinitializer, %arg
315 %inst1 = shufflevector <4 x i1> %inst, <4 x i1> zeroinitializer, <2 x i32> <i32 2, i32 0>
316 %inst2 = shufflevector <2 x i1> %inst1, <2 x i1> zeroinitializer, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
317 %inst3 = select <4 x i1> %inst2, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> zeroinitializer
321 define <4 x i32> @shuffle_zip3(<4 x i32> %arg) {
322 ; CHECK-LABEL: shuffle_zip3:
323 ; CHECK: // %bb.0: // %bb
324 ; CHECK-NEXT: cmgt.4s v0, v0, #0
325 ; CHECK-NEXT: uzp1.8h v1, v0, v0
326 ; CHECK-NEXT: xtn.4h v0, v0
327 ; CHECK-NEXT: xtn.4h v1, v1
328 ; CHECK-NEXT: zip2.4h v0, v0, v1
329 ; CHECK-NEXT: movi.4s v1, #1
330 ; CHECK-NEXT: zip1.4h v0, v0, v0
331 ; CHECK-NEXT: ushll.4s v0, v0, #0
332 ; CHECK-NEXT: and.16b v0, v0, v1
335 %inst = icmp slt <4 x i32> zeroinitializer, %arg
336 %inst1 = shufflevector <4 x i1> %inst, <4 x i1> zeroinitializer, <2 x i32> <i32 2, i32 0>
337 %inst2 = shufflevector <2 x i1> %inst1, <2 x i1> zeroinitializer, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
338 %inst3 = select <4 x i1> %inst2, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> zeroinitializer