1 ; RUN: llc -fast-isel -fast-isel-abort=1 -mtriple=aarch64-apple-darwin -verify-machineinstrs < %s | FileCheck %s
3 ; CHECK-LABEL: asr_zext_i1_i16
4 ; CHECK: uxth {{w[0-9]*}}, wzr
5 define zeroext i16 @asr_zext_i1_i16(i1 %b) {
11 ; CHECK-LABEL: asr_sext_i1_i16
12 ; CHECK: sbfx [[REG1:w[0-9]+]], {{w[0-9]*}}, #0, #1
13 ; CHECK-NEXT: sxth {{w[0-9]*}}, [[REG1]]
14 define signext i16 @asr_sext_i1_i16(i1 %b) {
15 %1 = sext i1 %b to i16
20 ; CHECK-LABEL: asr_zext_i1_i32
21 ; CHECK: mov {{w[0-9]*}}, wzr
22 define i32 @asr_zext_i1_i32(i1 %b) {
23 %1 = zext i1 %b to i32
28 ; CHECK-LABEL: asr_sext_i1_i32
29 ; CHECK: sbfx {{w[0-9]*}}, {{w[0-9]*}}, #0, #1
30 define i32 @asr_sext_i1_i32(i1 %b) {
31 %1 = sext i1 %b to i32
36 ; CHECK-LABEL: asr_zext_i1_i64
37 ; CHECK: mov {{x[0-9]*}}, xzr
38 define i64 @asr_zext_i1_i64(i1 %b) {
39 %1 = zext i1 %b to i64
44 ; CHECK-LABEL: asr_sext_i1_i64
45 ; CHECK: sbfx {{x[0-9]*}}, {{x[0-9]*}}, #0, #1
46 define i64 @asr_sext_i1_i64(i1 %b) {
47 %1 = sext i1 %b to i64
52 ; CHECK-LABEL: lsr_zext_i1_i16
53 ; CHECK: uxth {{w[0-9]*}}, wzr
54 define zeroext i16 @lsr_zext_i1_i16(i1 %b) {
55 %1 = zext i1 %b to i16
60 ; CHECK-LABEL: lsr_sext_i1_i16
61 ; CHECK: sbfx [[REG1:w[0-9]+]], {{w[0-9]*}}, #0, #1
62 ; CHECK-NEXT: ubfx [[REG2:w[0-9]+]], [[REG1]], #1, #15
63 ; CHECK-NEXT: sxth {{w[0-9]*}}, [[REG2]]
64 define signext i16 @lsr_sext_i1_i16(i1 %b) {
65 %1 = sext i1 %b to i16
70 ; CHECK-LABEL: lsr_zext_i1_i32
71 ; CHECK: mov {{w[0-9]*}}, wzr
72 define i32 @lsr_zext_i1_i32(i1 %b) {
73 %1 = zext i1 %b to i32
78 ; CHECK-LABEL: lsr_sext_i1_i32
79 ; CHECK: sbfx [[REG1:w[0-9]+]], {{w[0-9]*}}, #0, #1
80 ; CHECK-NEXT: lsr {{w[0-9]*}}, [[REG1:w[0-9]+]], #1
81 define i32 @lsr_sext_i1_i32(i1 %b) {
82 %1 = sext i1 %b to i32
87 ; CHECK-LABEL: lsr_zext_i1_i64
88 ; CHECK: mov {{x[0-9]*}}, xzr
89 define i64 @lsr_zext_i1_i64(i1 %b) {
90 %1 = zext i1 %b to i64
95 ; CHECK-LABEL: lsl_zext_i1_i16
96 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #1
97 define zeroext i16 @lsl_zext_i1_i16(i1 %b) {
98 %1 = zext i1 %b to i16
103 ; CHECK-LABEL: lsl_sext_i1_i16
104 ; CHECK: sbfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #1
105 define signext i16 @lsl_sext_i1_i16(i1 %b) {
106 %1 = sext i1 %b to i16
111 ; CHECK-LABEL: lsl_zext_i1_i32
112 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #1
113 define i32 @lsl_zext_i1_i32(i1 %b) {
114 %1 = zext i1 %b to i32
119 ; CHECK-LABEL: lsl_sext_i1_i32
120 ; CHECK: sbfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #1
121 define i32 @lsl_sext_i1_i32(i1 %b) {
122 %1 = sext i1 %b to i32
127 ; CHECK-LABEL: lsl_zext_i1_i64
128 ; CHECK: ubfiz {{x[0-9]*}}, {{x[0-9]*}}, #4, #1
129 define i64 @lsl_zext_i1_i64(i1 %b) {
130 %1 = zext i1 %b to i64
135 ; CHECK-LABEL: lsl_sext_i1_i64
136 ; CHECK: sbfiz {{x[0-9]*}}, {{x[0-9]*}}, #4, #1
137 define i64 @lsl_sext_i1_i64(i1 %b) {
138 %1 = sext i1 %b to i64
143 ; CHECK-LABEL: lslv_i8
144 ; CHECK: and [[REG1:w[0-9]+]], w1, #0xff
145 ; CHECK-NEXT: lsl [[REG2:w[0-9]+]], w0, [[REG1]]
146 ; CHECK-NEXT: and {{w[0-9]+}}, [[REG2]], #0xff
147 define zeroext i8 @lslv_i8(i8 %a, i8 %b) {
152 ; CHECK-LABEL: lsl_i8
153 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
154 define zeroext i8 @lsl_i8(i8 %a) {
159 ; CHECK-LABEL: lsl_zext_i8_i16
160 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #8
161 define zeroext i16 @lsl_zext_i8_i16(i8 %b) {
162 %1 = zext i8 %b to i16
167 ; CHECK-LABEL: lsl_sext_i8_i16
168 ; CHECK: sbfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #8
169 define signext i16 @lsl_sext_i8_i16(i8 %b) {
170 %1 = sext i8 %b to i16
175 ; CHECK-LABEL: lsl_zext_i8_i32
176 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #8
177 define i32 @lsl_zext_i8_i32(i8 %b) {
178 %1 = zext i8 %b to i32
183 ; CHECK-LABEL: lsl_sext_i8_i32
184 ; CHECK: sbfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #8
185 define i32 @lsl_sext_i8_i32(i8 %b) {
186 %1 = sext i8 %b to i32
191 ; CHECK-LABEL: lsl_zext_i8_i64
192 ; CHECK: ubfiz {{x[0-9]*}}, {{x[0-9]*}}, #4, #8
193 define i64 @lsl_zext_i8_i64(i8 %b) {
194 %1 = zext i8 %b to i64
199 ; CHECK-LABEL: lsl_sext_i8_i64
200 ; CHECK: sbfiz {{x[0-9]*}}, {{x[0-9]*}}, #4, #8
201 define i64 @lsl_sext_i8_i64(i8 %b) {
202 %1 = sext i8 %b to i64
207 ; CHECK-LABEL: lslv_i16
208 ; CHECK: and [[REG1:w[0-9]+]], w1, #0xffff
209 ; CHECK-NEXT: lsl [[REG2:w[0-9]+]], w0, [[REG1]]
210 ; CHECK-NEXT: and {{w[0-9]+}}, [[REG2]], #0xffff
211 define zeroext i16 @lslv_i16(i16 %a, i16 %b) {
216 ; CHECK-LABEL: lsl_i16
217 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #8, #8
218 define zeroext i16 @lsl_i16(i16 %a) {
223 ; CHECK-LABEL: lsl_zext_i16_i32
224 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #8, #16
225 define i32 @lsl_zext_i16_i32(i16 %b) {
226 %1 = zext i16 %b to i32
231 ; CHECK-LABEL: lsl_sext_i16_i32
232 ; CHECK: sbfiz {{w[0-9]*}}, {{w[0-9]*}}, #8, #16
233 define i32 @lsl_sext_i16_i32(i16 %b) {
234 %1 = sext i16 %b to i32
239 ; CHECK-LABEL: lsl_zext_i16_i64
240 ; CHECK: ubfiz {{x[0-9]*}}, {{x[0-9]*}}, #8, #16
241 define i64 @lsl_zext_i16_i64(i16 %b) {
242 %1 = zext i16 %b to i64
247 ; CHECK-LABEL: lsl_sext_i16_i64
248 ; CHECK: sbfiz {{x[0-9]*}}, {{x[0-9]*}}, #8, #16
249 define i64 @lsl_sext_i16_i64(i16 %b) {
250 %1 = sext i16 %b to i64
255 ; CHECK-LABEL: lslv_i32
256 ; CHECK: lsl {{w[0-9]*}}, w0, w1
257 define zeroext i32 @lslv_i32(i32 %a, i32 %b) {
262 ; CHECK-LABEL: lsl_i32
263 ; CHECK: lsl {{w[0-9]*}}, {{w[0-9]*}}, #16
264 define zeroext i32 @lsl_i32(i32 %a) {
269 ; CHECK-LABEL: lsl_zext_i32_i64
270 ; CHECK: ubfiz {{x[0-9]+}}, {{x[0-9]+}}, #16, #32
271 define i64 @lsl_zext_i32_i64(i32 %b) {
272 %1 = zext i32 %b to i64
277 ; CHECK-LABEL: lsl_sext_i32_i64
278 ; CHECK: sbfiz {{x[0-9]+}}, {{x[0-9]+}}, #16, #32
279 define i64 @lsl_sext_i32_i64(i32 %b) {
280 %1 = sext i32 %b to i64
285 ; CHECK-LABEL: lslv_i64
286 ; CHECK: lsl {{x[0-9]*}}, x0, x1
287 define i64 @lslv_i64(i64 %a, i64 %b) {
292 ; CHECK-LABEL: lsl_i64
293 ; CHECK: lsl {{x[0-9]*}}, {{x[0-9]*}}, #32
294 define i64 @lsl_i64(i64 %a) {
299 ; CHECK-LABEL: lsrv_i8
300 ; CHECK: and [[REG1:w[0-9]+]], w0, #0xff
301 ; CHECK-NEXT: and [[REG2:w[0-9]+]], w1, #0xff
302 ; CHECK-NEXT: lsr [[REG3:w[0-9]+]], [[REG1]], [[REG2]]
303 ; CHECK-NEXT: and {{w[0-9]+}}, [[REG3]], #0xff
304 define zeroext i8 @lsrv_i8(i8 %a, i8 %b) {
309 ; CHECK-LABEL: lsr_i8
310 ; CHECK: ubfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
311 define zeroext i8 @lsr_i8(i8 %a) {
316 ; CHECK-LABEL: lsr_zext_i8_i16
317 ; CHECK: ubfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
318 define zeroext i16 @lsr_zext_i8_i16(i8 %b) {
319 %1 = zext i8 %b to i16
324 ; CHECK-LABEL: lsr_sext_i8_i16
325 ; CHECK: sxtb [[REG:w[0-9]+]], w0
326 ; CHECK-NEXT: ubfx {{w[0-9]*}}, [[REG]], #4, #12
327 define signext i16 @lsr_sext_i8_i16(i8 %b) {
328 %1 = sext i8 %b to i16
333 ; CHECK-LABEL: lsr_zext_i8_i32
334 ; CHECK: ubfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
335 define i32 @lsr_zext_i8_i32(i8 %b) {
336 %1 = zext i8 %b to i32
341 ; CHECK-LABEL: lsr_sext_i8_i32
342 ; CHECK: sxtb [[REG:w[0-9]+]], w0
343 ; CHECK-NEXT: lsr {{w[0-9]*}}, [[REG]], #4
344 define i32 @lsr_sext_i8_i32(i8 %b) {
345 %1 = sext i8 %b to i32
350 ; CHECK-LABEL: lsrv_i16
351 ; CHECK: and [[REG1:w[0-9]+]], w0, #0xffff
352 ; CHECK-NEXT: and [[REG2:w[0-9]+]], w1, #0xffff
353 ; CHECK-NEXT: lsr [[REG3:w[0-9]+]], [[REG1]], [[REG2]]
354 ; CHECK-NEXT: and {{w[0-9]+}}, [[REG3]], #0xffff
355 define zeroext i16 @lsrv_i16(i16 %a, i16 %b) {
360 ; CHECK-LABEL: lsr_i16
361 ; CHECK: ubfx {{w[0-9]*}}, {{w[0-9]*}}, #8, #8
362 define zeroext i16 @lsr_i16(i16 %a) {
367 ; CHECK-LABEL: lsrv_i32
368 ; CHECK: lsr {{w[0-9]*}}, w0, w1
369 define zeroext i32 @lsrv_i32(i32 %a, i32 %b) {
374 ; CHECK-LABEL: lsr_i32
375 ; CHECK: lsr {{w[0-9]*}}, {{w[0-9]*}}, #16
376 define zeroext i32 @lsr_i32(i32 %a) {
381 ; CHECK-LABEL: lsrv_i64
382 ; CHECK: lsr {{x[0-9]*}}, x0, x1
383 define i64 @lsrv_i64(i64 %a, i64 %b) {
388 ; CHECK-LABEL: lsr_i64
389 ; CHECK: lsr {{x[0-9]*}}, {{x[0-9]*}}, #32
390 define i64 @lsr_i64(i64 %a) {
395 ; CHECK-LABEL: asrv_i8
396 ; CHECK: sxtb [[REG1:w[0-9]+]], w0
397 ; CHECK-NEXT: and [[REG2:w[0-9]+]], w1, #0xff
398 ; CHECK-NEXT: asr [[REG3:w[0-9]+]], [[REG1]], [[REG2]]
399 ; CHECK-NEXT: and {{w[0-9]+}}, [[REG3]], #0xff
400 define zeroext i8 @asrv_i8(i8 %a, i8 %b) {
405 ; CHECK-LABEL: asr_i8
406 ; CHECK: sbfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
407 define zeroext i8 @asr_i8(i8 %a) {
412 ; CHECK-LABEL: asr_zext_i8_i16
413 ; CHECK: ubfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
414 define zeroext i16 @asr_zext_i8_i16(i8 %b) {
415 %1 = zext i8 %b to i16
420 ; CHECK-LABEL: asr_sext_i8_i16
421 ; CHECK: sbfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
422 define signext i16 @asr_sext_i8_i16(i8 %b) {
423 %1 = sext i8 %b to i16
428 ; CHECK-LABEL: asr_zext_i8_i32
429 ; CHECK: ubfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
430 define i32 @asr_zext_i8_i32(i8 %b) {
431 %1 = zext i8 %b to i32
436 ; CHECK-LABEL: asr_sext_i8_i32
437 ; CHECK: sbfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
438 define i32 @asr_sext_i8_i32(i8 %b) {
439 %1 = sext i8 %b to i32
444 ; CHECK-LABEL: asrv_i16
445 ; CHECK: sxth [[REG1:w[0-9]+]], w0
446 ; CHECK-NEXT: and [[REG2:w[0-9]+]], w1, #0xffff
447 ; CHECK-NEXT: asr [[REG3:w[0-9]+]], [[REG1]], [[REG2]]
448 ; CHECK-NEXT: and {{w[0-9]+}}, [[REG3]], #0xffff
449 define zeroext i16 @asrv_i16(i16 %a, i16 %b) {
454 ; CHECK-LABEL: asr_i16
455 ; CHECK: sbfx {{w[0-9]*}}, {{w[0-9]*}}, #8, #8
456 define zeroext i16 @asr_i16(i16 %a) {
461 ; CHECK-LABEL: asrv_i32
462 ; CHECK: asr {{w[0-9]*}}, w0, w1
463 define zeroext i32 @asrv_i32(i32 %a, i32 %b) {
468 ; CHECK-LABEL: asr_i32
469 ; CHECK: asr {{w[0-9]*}}, {{w[0-9]*}}, #16
470 define zeroext i32 @asr_i32(i32 %a) {
475 ; CHECK-LABEL: asrv_i64
476 ; CHECK: asr {{x[0-9]*}}, x0, x1
477 define i64 @asrv_i64(i64 %a, i64 %b) {
482 ; CHECK-LABEL: asr_i64
483 ; CHECK: asr {{x[0-9]*}}, {{x[0-9]*}}, #32
484 define i64 @asr_i64(i64 %a) {
489 ; CHECK-LABEL: shift_test1
490 ; CHECK: ubfiz {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
491 ; CHECK-NEXT: sbfx {{w[0-9]*}}, {{w[0-9]*}}, #4, #4
492 define i32 @shift_test1(i8 %a) {
495 %3 = sext i8 %2 to i32
501 ; CHECK-LABEL: shl_zero
503 define i32 @shl_zero(i32 %a) {
508 ; CHECK-LABEL: lshr_zero
510 define i32 @lshr_zero(i32 %a) {
515 ; CHECK-LABEL: ashr_zero
517 define i32 @ashr_zero(i32 %a) {
522 ; CHECK-LABEL: shl_zext_zero
523 ; CHECK: ubfx x0, x0, #0, #32
524 define i64 @shl_zext_zero(i32 %a) {
525 %1 = zext i32 %a to i64
530 ; CHECK-LABEL: lshr_zext_zero
531 ; CHECK: ubfx x0, x0, #0, #32
532 define i64 @lshr_zext_zero(i32 %a) {
533 %1 = zext i32 %a to i64
538 ; CHECK-LABEL: ashr_zext_zero
539 ; CHECK: ubfx x0, x0, #0, #32
540 define i64 @ashr_zext_zero(i32 %a) {
541 %1 = zext i32 %a to i64