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 void @testLeftGood8x8(<8 x i8> %src1, <8 x i8> %src2, ptr %dest) nounwind {
5 ; CHECK-LABEL: testLeftGood8x8:
7 ; CHECK-NEXT: sli.8b v0, v1, #3
8 ; CHECK-NEXT: str d0, [x0]
10 %and.i = and <8 x i8> %src1, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
11 %vshl_n = shl <8 x i8> %src2, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
12 %result = or <8 x i8> %and.i, %vshl_n
13 store <8 x i8> %result, ptr %dest, align 8
17 define void @testLeftBad8x8(<8 x i8> %src1, <8 x i8> %src2, ptr %dest) nounwind {
18 ; CHECK-LABEL: testLeftBad8x8:
20 ; CHECK-NEXT: movi.8b v2, #165
21 ; CHECK-NEXT: add.8b v1, v1, v1
22 ; CHECK-NEXT: and.8b v0, v0, v2
23 ; CHECK-NEXT: orr.8b v0, v0, v1
24 ; CHECK-NEXT: str d0, [x0]
26 %and.i = and <8 x i8> %src1, <i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165>
27 %vshl_n = shl <8 x i8> %src2, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
28 %result = or <8 x i8> %and.i, %vshl_n
29 store <8 x i8> %result, ptr %dest, align 8
33 define void @testRightGood8x8(<8 x i8> %src1, <8 x i8> %src2, ptr %dest) nounwind {
34 ; CHECK-LABEL: testRightGood8x8:
36 ; CHECK-NEXT: sri.8b v0, v1, #3
37 ; CHECK-NEXT: str d0, [x0]
39 %and.i = and <8 x i8> %src1, <i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224>
40 %vshl_n = lshr <8 x i8> %src2, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
41 %result = or <8 x i8> %and.i, %vshl_n
42 store <8 x i8> %result, ptr %dest, align 8
46 define void @testRightBad8x8(<8 x i8> %src1, <8 x i8> %src2, ptr %dest) nounwind {
47 ; CHECK-LABEL: testRightBad8x8:
49 ; CHECK-NEXT: movi.8b v2, #165
50 ; CHECK-NEXT: ushr.8b v1, v1, #1
51 ; CHECK-NEXT: and.8b v0, v0, v2
52 ; CHECK-NEXT: orr.8b v0, v0, v1
53 ; CHECK-NEXT: str d0, [x0]
55 %and.i = and <8 x i8> %src1, <i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165>
56 %vshl_n = lshr <8 x i8> %src2, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
57 %result = or <8 x i8> %and.i, %vshl_n
58 store <8 x i8> %result, ptr %dest, align 8
62 define void @testLeftGood16x8(<16 x i8> %src1, <16 x i8> %src2, ptr %dest) nounwind {
63 ; CHECK-LABEL: testLeftGood16x8:
65 ; CHECK-NEXT: sli.16b v0, v1, #3
66 ; CHECK-NEXT: str q0, [x0]
68 %and.i = and <16 x i8> %src1, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
69 %vshl_n = shl <16 x i8> %src2, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
70 %result = or <16 x i8> %and.i, %vshl_n
71 store <16 x i8> %result, ptr %dest, align 16
75 define void @testLeftBad16x8(<16 x i8> %src1, <16 x i8> %src2, ptr %dest) nounwind {
76 ; CHECK-LABEL: testLeftBad16x8:
78 ; CHECK-NEXT: movi.16b v2, #165
79 ; CHECK-NEXT: add.16b v1, v1, v1
80 ; CHECK-NEXT: and.16b v0, v0, v2
81 ; CHECK-NEXT: orr.16b v0, v0, v1
82 ; CHECK-NEXT: str q0, [x0]
84 %and.i = and <16 x i8> %src1, <i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165>
85 %vshl_n = shl <16 x i8> %src2, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
86 %result = or <16 x i8> %and.i, %vshl_n
87 store <16 x i8> %result, ptr %dest, align 16
91 define void @testRightGood16x8(<16 x i8> %src1, <16 x i8> %src2, ptr %dest) nounwind {
92 ; CHECK-LABEL: testRightGood16x8:
94 ; CHECK-NEXT: sri.16b v0, v1, #3
95 ; CHECK-NEXT: str q0, [x0]
97 %and.i = and <16 x i8> %src1, <i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224, i8 224>
98 %vshl_n = lshr <16 x i8> %src2, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
99 %result = or <16 x i8> %and.i, %vshl_n
100 store <16 x i8> %result, ptr %dest, align 16
104 define void @testRightBad16x8(<16 x i8> %src1, <16 x i8> %src2, ptr %dest) nounwind {
105 ; CHECK-LABEL: testRightBad16x8:
107 ; CHECK-NEXT: movi.16b v2, #165
108 ; CHECK-NEXT: ushr.16b v1, v1, #1
109 ; CHECK-NEXT: and.16b v0, v0, v2
110 ; CHECK-NEXT: orr.16b v0, v0, v1
111 ; CHECK-NEXT: str q0, [x0]
113 %and.i = and <16 x i8> %src1, <i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165, i8 165>
114 %vshl_n = lshr <16 x i8> %src2, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
115 %result = or <16 x i8> %and.i, %vshl_n
116 store <16 x i8> %result, ptr %dest, align 16
120 define void @testLeftGood4x16(<4 x i16> %src1, <4 x i16> %src2, ptr %dest) nounwind {
121 ; CHECK-LABEL: testLeftGood4x16:
123 ; CHECK-NEXT: sli.4h v0, v1, #14
124 ; CHECK-NEXT: str d0, [x0]
126 %and.i = and <4 x i16> %src1, <i16 16383, i16 16383, i16 16383, i16 16383>
127 %vshl_n = shl <4 x i16> %src2, <i16 14, i16 14, i16 14, i16 14>
128 %result = or <4 x i16> %and.i, %vshl_n
129 store <4 x i16> %result, ptr %dest, align 8
133 define void @testLeftBad4x16(<4 x i16> %src1, <4 x i16> %src2, ptr %dest) nounwind {
134 ; CHECK-LABEL: testLeftBad4x16:
136 ; CHECK-NEXT: mov w8, #16500
137 ; CHECK-NEXT: shl.4h v1, v1, #14
138 ; CHECK-NEXT: dup.4h v2, w8
139 ; CHECK-NEXT: and.8b v0, v0, v2
140 ; CHECK-NEXT: orr.8b v0, v0, v1
141 ; CHECK-NEXT: str d0, [x0]
143 %and.i = and <4 x i16> %src1, <i16 16500, i16 16500, i16 16500, i16 16500>
144 %vshl_n = shl <4 x i16> %src2, <i16 14, i16 14, i16 14, i16 14>
145 %result = or <4 x i16> %and.i, %vshl_n
146 store <4 x i16> %result, ptr %dest, align 8
150 define void @testRightGood4x16(<4 x i16> %src1, <4 x i16> %src2, ptr %dest) nounwind {
151 ; CHECK-LABEL: testRightGood4x16:
153 ; CHECK-NEXT: sri.4h v0, v1, #14
154 ; CHECK-NEXT: str d0, [x0]
156 %and.i = and <4 x i16> %src1, <i16 65532, i16 65532, i16 65532, i16 65532>
157 %vshl_n = lshr <4 x i16> %src2, <i16 14, i16 14, i16 14, i16 14>
158 %result = or <4 x i16> %and.i, %vshl_n
159 store <4 x i16> %result, ptr %dest, align 8
163 define void @testRightBad4x16(<4 x i16> %src1, <4 x i16> %src2, ptr %dest) nounwind {
164 ; CHECK-LABEL: testRightBad4x16:
166 ; CHECK-NEXT: mov w8, #16500
167 ; CHECK-NEXT: dup.4h v2, w8
168 ; CHECK-NEXT: and.8b v0, v0, v2
169 ; CHECK-NEXT: usra.4h v0, v1, #14
170 ; CHECK-NEXT: str d0, [x0]
172 %and.i = and <4 x i16> %src1, <i16 16500, i16 16500, i16 16500, i16 16500>
173 %vshl_n = lshr <4 x i16> %src2, <i16 14, i16 14, i16 14, i16 14>
174 %result = or <4 x i16> %and.i, %vshl_n
175 store <4 x i16> %result, ptr %dest, align 8
179 define void @testLeftGood8x16(<8 x i16> %src1, <8 x i16> %src2, ptr %dest) nounwind {
180 ; CHECK-LABEL: testLeftGood8x16:
182 ; CHECK-NEXT: sli.8h v0, v1, #14
183 ; CHECK-NEXT: str q0, [x0]
185 %and.i = and <8 x i16> %src1, <i16 16383, i16 16383, i16 16383, i16 16383, i16 16383, i16 16383, i16 16383, i16 16383>
186 %vshl_n = shl <8 x i16> %src2, <i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14>
187 %result = or <8 x i16> %and.i, %vshl_n
188 store <8 x i16> %result, ptr %dest, align 16
192 define void @testLeftBad8x16(<8 x i16> %src1, <8 x i16> %src2, ptr %dest) nounwind {
193 ; CHECK-LABEL: testLeftBad8x16:
195 ; CHECK-NEXT: mov w8, #16500
196 ; CHECK-NEXT: shl.8h v1, v1, #14
197 ; CHECK-NEXT: dup.8h v2, w8
198 ; CHECK-NEXT: and.16b v0, v0, v2
199 ; CHECK-NEXT: orr.16b v0, v0, v1
200 ; CHECK-NEXT: str q0, [x0]
202 %and.i = and <8 x i16> %src1, <i16 16500, i16 16500, i16 16500, i16 16500, i16 16500, i16 16500, i16 16500, i16 16500>
203 %vshl_n = shl <8 x i16> %src2, <i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14>
204 %result = or <8 x i16> %and.i, %vshl_n
205 store <8 x i16> %result, ptr %dest, align 16
209 define void @testRightGood8x16(<8 x i16> %src1, <8 x i16> %src2, ptr %dest) nounwind {
210 ; CHECK-LABEL: testRightGood8x16:
212 ; CHECK-NEXT: sri.8h v0, v1, #14
213 ; CHECK-NEXT: str q0, [x0]
215 %and.i = and <8 x i16> %src1, <i16 65532, i16 65532, i16 65532, i16 65532, i16 65532, i16 65532, i16 65532, i16 65532>
216 %vshl_n = lshr <8 x i16> %src2, <i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14>
217 %result = or <8 x i16> %and.i, %vshl_n
218 store <8 x i16> %result, ptr %dest, align 16
222 define void @testRightBad8x16(<8 x i16> %src1, <8 x i16> %src2, ptr %dest) nounwind {
223 ; CHECK-LABEL: testRightBad8x16:
225 ; CHECK-NEXT: mov w8, #16500
226 ; CHECK-NEXT: dup.8h v2, w8
227 ; CHECK-NEXT: and.16b v0, v0, v2
228 ; CHECK-NEXT: usra.8h v0, v1, #14
229 ; CHECK-NEXT: str q0, [x0]
231 %and.i = and <8 x i16> %src1, <i16 16500, i16 16500, i16 16500, i16 16500, i16 16500, i16 16500, i16 16500, i16 16500>
232 %vshl_n = lshr <8 x i16> %src2, <i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14, i16 14>
233 %result = or <8 x i16> %and.i, %vshl_n
234 store <8 x i16> %result, ptr %dest, align 16
238 define void @testLeftGood2x32(<2 x i32> %src1, <2 x i32> %src2, ptr %dest) nounwind {
239 ; CHECK-LABEL: testLeftGood2x32:
241 ; CHECK-NEXT: sli.2s v0, v1, #22
242 ; CHECK-NEXT: str d0, [x0]
244 %and.i = and <2 x i32> %src1, <i32 4194303, i32 4194303>
245 %vshl_n = shl <2 x i32> %src2, <i32 22, i32 22>
246 %result = or <2 x i32> %and.i, %vshl_n
247 store <2 x i32> %result, ptr %dest, align 8
251 define void @testLeftBad2x32(<2 x i32> %src1, <2 x i32> %src2, ptr %dest) nounwind {
252 ; CHECK-LABEL: testLeftBad2x32:
254 ; CHECK-NEXT: mov w8, #4194300
255 ; CHECK-NEXT: shl.2s v1, v1, #22
256 ; CHECK-NEXT: dup.2s v2, w8
257 ; CHECK-NEXT: and.8b v0, v0, v2
258 ; CHECK-NEXT: orr.8b v0, v0, v1
259 ; CHECK-NEXT: str d0, [x0]
261 %and.i = and <2 x i32> %src1, <i32 4194300, i32 4194300>
262 %vshl_n = shl <2 x i32> %src2, <i32 22, i32 22>
263 %result = or <2 x i32> %and.i, %vshl_n
264 store <2 x i32> %result, ptr %dest, align 8
268 define void @testRightGood2x32(<2 x i32> %src1, <2 x i32> %src2, ptr %dest) nounwind {
269 ; CHECK-LABEL: testRightGood2x32:
271 ; CHECK-NEXT: sri.2s v0, v1, #22
272 ; CHECK-NEXT: str d0, [x0]
274 %and.i = and <2 x i32> %src1, <i32 4294966272, i32 4294966272>
275 %vshl_n = lshr <2 x i32> %src2, <i32 22, i32 22>
276 %result = or <2 x i32> %and.i, %vshl_n
277 store <2 x i32> %result, ptr %dest, align 8
281 define void @testRightBad2x32(<2 x i32> %src1, <2 x i32> %src2, ptr %dest) nounwind {
282 ; CHECK-LABEL: testRightBad2x32:
284 ; CHECK-NEXT: mov w8, #4194300
285 ; CHECK-NEXT: ushr.2s v1, v1, #22
286 ; CHECK-NEXT: dup.2s v2, w8
287 ; CHECK-NEXT: and.8b v0, v0, v2
288 ; CHECK-NEXT: orr.8b v0, v0, v1
289 ; CHECK-NEXT: str d0, [x0]
291 %and.i = and <2 x i32> %src1, <i32 4194300, i32 4194300>
292 %vshl_n = lshr <2 x i32> %src2, <i32 22, i32 22>
293 %result = or <2 x i32> %and.i, %vshl_n
294 store <2 x i32> %result, ptr %dest, align 8
298 define void @testLeftGood4x32(<4 x i32> %src1, <4 x i32> %src2, ptr %dest) nounwind {
299 ; CHECK-LABEL: testLeftGood4x32:
301 ; CHECK-NEXT: sli.4s v0, v1, #22
302 ; CHECK-NEXT: str q0, [x0]
304 %and.i = and <4 x i32> %src1, <i32 4194303, i32 4194303, i32 4194303, i32 4194303>
305 %vshl_n = shl <4 x i32> %src2, <i32 22, i32 22, i32 22, i32 22>
306 %result = or <4 x i32> %and.i, %vshl_n
307 store <4 x i32> %result, ptr %dest, align 16
311 define void @testLeftBad4x32(<4 x i32> %src1, <4 x i32> %src2, ptr %dest) nounwind {
312 ; CHECK-LABEL: testLeftBad4x32:
314 ; CHECK-NEXT: mov w8, #4194300
315 ; CHECK-NEXT: shl.4s v1, v1, #22
316 ; CHECK-NEXT: dup.4s v2, w8
317 ; CHECK-NEXT: and.16b v0, v0, v2
318 ; CHECK-NEXT: orr.16b v0, v0, v1
319 ; CHECK-NEXT: str q0, [x0]
321 %and.i = and <4 x i32> %src1, <i32 4194300, i32 4194300, i32 4194300, i32 4194300>
322 %vshl_n = shl <4 x i32> %src2, <i32 22, i32 22, i32 22, i32 22>
323 %result = or <4 x i32> %and.i, %vshl_n
324 store <4 x i32> %result, ptr %dest, align 16
328 define void @testRightGood4x32(<4 x i32> %src1, <4 x i32> %src2, ptr %dest) nounwind {
329 ; CHECK-LABEL: testRightGood4x32:
331 ; CHECK-NEXT: sri.4s v0, v1, #22
332 ; CHECK-NEXT: str q0, [x0]
334 %and.i = and <4 x i32> %src1, <i32 4294966272, i32 4294966272, i32 4294966272, i32 4294966272>
335 %vshl_n = lshr <4 x i32> %src2, <i32 22, i32 22, i32 22, i32 22>
336 %result = or <4 x i32> %and.i, %vshl_n
337 store <4 x i32> %result, ptr %dest, align 16
341 define void @testRightBad4x32(<4 x i32> %src1, <4 x i32> %src2, ptr %dest) nounwind {
342 ; CHECK-LABEL: testRightBad4x32:
344 ; CHECK-NEXT: mov w8, #4194300
345 ; CHECK-NEXT: ushr.4s v1, v1, #22
346 ; CHECK-NEXT: dup.4s v2, w8
347 ; CHECK-NEXT: and.16b v0, v0, v2
348 ; CHECK-NEXT: orr.16b v0, v0, v1
349 ; CHECK-NEXT: str q0, [x0]
351 %and.i = and <4 x i32> %src1, <i32 4194300, i32 4194300, i32 4194300, i32 4194300>
352 %vshl_n = lshr <4 x i32> %src2, <i32 22, i32 22, i32 22, i32 22>
353 %result = or <4 x i32> %and.i, %vshl_n
354 store <4 x i32> %result, ptr %dest, align 16
358 define void @testLeftGood2x64(<2 x i64> %src1, <2 x i64> %src2, ptr %dest) nounwind {
359 ; CHECK-LABEL: testLeftGood2x64:
361 ; CHECK-NEXT: sli.2d v0, v1, #48
362 ; CHECK-NEXT: str q0, [x0]
364 %and.i = and <2 x i64> %src1, <i64 281474976710655, i64 281474976710655>
365 %vshl_n = shl <2 x i64> %src2, <i64 48, i64 48>
366 %result = or <2 x i64> %and.i, %vshl_n
367 store <2 x i64> %result, ptr %dest, align 16
371 define void @testLeftBad2x64(<2 x i64> %src1, <2 x i64> %src2, ptr %dest) nounwind {
372 ; CHECK-LABEL: testLeftBad2x64:
374 ; CHECK-NEXT: mov x8, #10
375 ; CHECK-NEXT: shl.2d v1, v1, #48
376 ; CHECK-NEXT: movk x8, #1, lsl #48
377 ; CHECK-NEXT: dup.2d v2, x8
378 ; CHECK-NEXT: and.16b v0, v0, v2
379 ; CHECK-NEXT: orr.16b v0, v0, v1
380 ; CHECK-NEXT: str q0, [x0]
382 %and.i = and <2 x i64> %src1, <i64 281474976710666, i64 281474976710666>
383 %vshl_n = shl <2 x i64> %src2, <i64 48, i64 48>
384 %result = or <2 x i64> %and.i, %vshl_n
385 store <2 x i64> %result, ptr %dest, align 16
389 define void @testRightGood2x64(<2 x i64> %src1, <2 x i64> %src2, ptr %dest) nounwind {
390 ; CHECK-LABEL: testRightGood2x64:
392 ; CHECK-NEXT: sri.2d v0, v1, #48
393 ; CHECK-NEXT: str q0, [x0]
395 %and.i = and <2 x i64> %src1, <i64 18446744073709486080, i64 18446744073709486080>
396 %vshl_n = lshr <2 x i64> %src2, <i64 48, i64 48>
397 %result = or <2 x i64> %and.i, %vshl_n
398 store <2 x i64> %result, ptr %dest, align 16
402 define void @testRightBad2x64(<2 x i64> %src1, <2 x i64> %src2, ptr %dest) nounwind {
403 ; CHECK-LABEL: testRightBad2x64:
405 ; CHECK-NEXT: mov x8, #10
406 ; CHECK-NEXT: ushr.2d v1, v1, #48
407 ; CHECK-NEXT: movk x8, #1, lsl #48
408 ; CHECK-NEXT: dup.2d v2, x8
409 ; CHECK-NEXT: and.16b v0, v0, v2
410 ; CHECK-NEXT: orr.16b v0, v0, v1
411 ; CHECK-NEXT: str q0, [x0]
413 %and.i = and <2 x i64> %src1, <i64 281474976710666, i64 281474976710666>
414 %vshl_n = lshr <2 x i64> %src2, <i64 48, i64 48>
415 %result = or <2 x i64> %and.i, %vshl_n
416 store <2 x i64> %result, ptr %dest, align 16
420 define void @testLeftShouldNotCreateSLI1x128(<1 x i128> %src1, <1 x i128> %src2, ptr %dest) nounwind {
421 ; CHECK-LABEL: testLeftShouldNotCreateSLI1x128:
423 ; CHECK-NEXT: bfi x1, x2, #6, #58
424 ; CHECK-NEXT: stp x0, x1, [x4]
426 %and.i = and <1 x i128> %src1, <i128 1180591620717411303423>
427 %vshl_n = shl <1 x i128> %src2, <i128 70>
428 %result = or <1 x i128> %and.i, %vshl_n
429 store <1 x i128> %result, ptr %dest, align 16
433 define void @testLeftNotAllConstantBuildVec8x8(<8 x i8> %src1, <8 x i8> %src2, ptr %dest) nounwind {
434 ; CHECK-LABEL: testLeftNotAllConstantBuildVec8x8:
436 ; CHECK-NEXT: adrp x8, .LCPI29_0
437 ; CHECK-NEXT: shl.8b v1, v1, #3
438 ; CHECK-NEXT: ldr d2, [x8, :lo12:.LCPI29_0]
439 ; CHECK-NEXT: and.8b v0, v0, v2
440 ; CHECK-NEXT: orr.8b v0, v0, v1
441 ; CHECK-NEXT: str d0, [x0]
443 %and.i = and <8 x i8> %src1, <i8 7, i8 7, i8 255, i8 7, i8 7, i8 7, i8 255, i8 7>
444 %vshl_n = shl <8 x i8> %src2, <i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3, i8 3>
445 %result = or <8 x i8> %and.i, %vshl_n
446 store <8 x i8> %result, ptr %dest, align 8