1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X32
3 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefix=X64
6 define i8 @test_zext_i1toi8(i1 %a) {
11 define i16 @test_zext_i1toi16(i1 %a) {
12 %r = zext i1 %a to i16
16 define i32 @test_zext_i1(i8 %a) {
17 %val = trunc i8 %a to i1
18 %r = zext i1 %val to i32
22 define i16 @test_zext_i8toi16(i8 %val) {
23 %r = zext i8 %val to i16
27 define i32 @test_zext_i8(i8 %val) {
28 %r = zext i8 %val to i32
32 define i32 @test_zext_i16(i16 %val) {
33 %r = zext i16 %val to i32
37 define i8 @test_sext_i1toi8(i1 %a) {
42 define i16 @test_sext_i1toi16(i1 %a) {
43 %r = sext i1 %a to i16
47 define i32 @test_sext_i1(i8 %a) {
48 %val = trunc i8 %a to i1
49 %r = sext i1 %val to i32
53 define i16 @test_sext_i8toi16(i8 %val) {
54 %r = sext i8 %val to i16
58 define i32 @test_sext_i8(i8 %val) {
59 %r = sext i8 %val to i32
63 define i32 @test_sext_i16(i16 %val) {
64 %r = sext i16 %val to i32
68 define void @test_anyext_i1toi8(i1 %a) {
72 define void @test_anyext_i1toi16(i1 %a) {
76 define void @test_anyext_i1(i8 %a) {
80 define void @test_anyext_i8toi16(i8 %val) {
84 define void @test_anyext_i8(i8 %val) {
88 define void @test_anyext_i16(i16 %val) {
94 name: test_zext_i1toi8
97 regBankSelected: false
99 - { id: 0, class: _, preferred-register: '' }
100 - { id: 1, class: _, preferred-register: '' }
101 - { id: 2, class: _, preferred-register: '' }
106 ; X32-LABEL: name: test_zext_i1toi8
109 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
110 ; X32-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
111 ; X32-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
112 ; X32-NEXT: [[AND:%[0-9]+]]:_(s8) = G_AND [[TRUNC]], [[C]]
113 ; X32-NEXT: $al = COPY [[AND]](s8)
114 ; X32-NEXT: RET 0, implicit $al
116 ; X64-LABEL: name: test_zext_i1toi8
119 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
120 ; X64-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
121 ; X64-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 1
122 ; X64-NEXT: [[AND:%[0-9]+]]:_(s8) = G_AND [[TRUNC]], [[C]]
123 ; X64-NEXT: $al = COPY [[AND]](s8)
124 ; X64-NEXT: RET 0, implicit $al
125 %1:_(s32) = COPY $edi
126 %0:_(s1) = G_TRUNC %1(s32)
127 %2:_(s8) = G_ZEXT %0(s1)
133 name: test_zext_i1toi16
136 regBankSelected: false
138 - { id: 0, class: _, preferred-register: '' }
139 - { id: 1, class: _, preferred-register: '' }
144 ; X32-LABEL: name: test_zext_i1toi16
147 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
148 ; X32-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
149 ; X32-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 1
150 ; X32-NEXT: [[AND:%[0-9]+]]:_(s16) = G_AND [[TRUNC]], [[C]]
151 ; X32-NEXT: $ax = COPY [[AND]](s16)
152 ; X32-NEXT: RET 0, implicit $ax
154 ; X64-LABEL: name: test_zext_i1toi16
157 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
158 ; X64-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
159 ; X64-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 1
160 ; X64-NEXT: [[AND:%[0-9]+]]:_(s16) = G_AND [[TRUNC]], [[C]]
161 ; X64-NEXT: $ax = COPY [[AND]](s16)
162 ; X64-NEXT: RET 0, implicit $ax
163 %1:_(s32) = COPY $edi
164 %0:_(s1) = G_TRUNC %1(s32)
165 %2:_(s16) = G_ZEXT %0(s1)
174 regBankSelected: false
176 - { id: 0, class: _ }
177 - { id: 1, class: _ }
178 - { id: 2, class: _ }
183 ; X32-LABEL: name: test_zext_i1
186 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
187 ; X32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s8)
188 ; X32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
189 ; X32-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C]]
190 ; X32-NEXT: $eax = COPY [[AND]](s32)
191 ; X32-NEXT: RET 0, implicit $eax
193 ; X64-LABEL: name: test_zext_i1
196 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
197 ; X64-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s8)
198 ; X64-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
199 ; X64-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C]]
200 ; X64-NEXT: $eax = COPY [[AND]](s32)
201 ; X64-NEXT: RET 0, implicit $eax
203 %1(s1) = G_TRUNC %0(s8)
204 %2(s32) = G_ZEXT %1(s1)
210 name: test_zext_i8toi16
213 regBankSelected: false
215 - { id: 0, class: _, preferred-register: '' }
216 - { id: 1, class: _, preferred-register: '' }
221 ; X32-LABEL: name: test_zext_i8toi16
224 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
225 ; X32-NEXT: [[ZEXT:%[0-9]+]]:_(s16) = G_ZEXT [[COPY]](s8)
226 ; X32-NEXT: $ax = COPY [[ZEXT]](s16)
227 ; X32-NEXT: RET 0, implicit $ax
229 ; X64-LABEL: name: test_zext_i8toi16
232 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
233 ; X64-NEXT: [[ZEXT:%[0-9]+]]:_(s16) = G_ZEXT [[COPY]](s8)
234 ; X64-NEXT: $ax = COPY [[ZEXT]](s16)
235 ; X64-NEXT: RET 0, implicit $ax
237 %1(s16) = G_ZEXT %0(s8)
246 regBankSelected: false
248 - { id: 0, class: _ }
249 - { id: 1, class: _ }
254 ; X32-LABEL: name: test_zext_i8
257 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
258 ; X32-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s8)
259 ; X32-NEXT: $eax = COPY [[ZEXT]](s32)
260 ; X32-NEXT: RET 0, implicit $eax
262 ; X64-LABEL: name: test_zext_i8
265 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
266 ; X64-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s8)
267 ; X64-NEXT: $eax = COPY [[ZEXT]](s32)
268 ; X64-NEXT: RET 0, implicit $eax
270 %1(s32) = G_ZEXT %0(s8)
279 regBankSelected: false
281 - { id: 0, class: _ }
282 - { id: 1, class: _ }
287 ; X32-LABEL: name: test_zext_i16
290 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $di
291 ; X32-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s16)
292 ; X32-NEXT: $eax = COPY [[ZEXT]](s32)
293 ; X32-NEXT: RET 0, implicit $eax
295 ; X64-LABEL: name: test_zext_i16
298 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $di
299 ; X64-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[COPY]](s16)
300 ; X64-NEXT: $eax = COPY [[ZEXT]](s32)
301 ; X64-NEXT: RET 0, implicit $eax
303 %1(s32) = G_ZEXT %0(s16)
309 name: test_sext_i1toi8
312 regBankSelected: false
314 - { id: 0, class: _, preferred-register: '' }
315 - { id: 1, class: _, preferred-register: '' }
320 ; X32-LABEL: name: test_sext_i1toi8
323 ; X32-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
324 ; X32-NEXT: $al = COPY [[C]](s8)
325 ; X32-NEXT: RET 0, implicit $al
327 ; X64-LABEL: name: test_sext_i1toi8
330 ; X64-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 0
331 ; X64-NEXT: $al = COPY [[C]](s8)
332 ; X64-NEXT: RET 0, implicit $al
333 %0(s1) = G_IMPLICIT_DEF
334 %1(s8) = G_SEXT %0(s1)
340 name: test_sext_i1toi16
343 regBankSelected: false
345 - { id: 0, class: _, preferred-register: '' }
346 - { id: 1, class: _, preferred-register: '' }
351 ; X32-LABEL: name: test_sext_i1toi16
354 ; X32-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
355 ; X32-NEXT: $ax = COPY [[C]](s16)
356 ; X32-NEXT: RET 0, implicit $ax
358 ; X64-LABEL: name: test_sext_i1toi16
361 ; X64-NEXT: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
362 ; X64-NEXT: $ax = COPY [[C]](s16)
363 ; X64-NEXT: RET 0, implicit $ax
364 %0(s1) = G_IMPLICIT_DEF
365 %1(s16) = G_SEXT %0(s1)
374 regBankSelected: false
376 - { id: 0, class: _ }
377 - { id: 1, class: _ }
378 - { id: 2, class: _ }
383 ; X32-LABEL: name: test_sext_i1
386 ; X32-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
387 ; X32-NEXT: $eax = COPY [[C]](s32)
388 ; X32-NEXT: RET 0, implicit $eax
390 ; X64-LABEL: name: test_sext_i1
393 ; X64-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
394 ; X64-NEXT: $eax = COPY [[C]](s32)
395 ; X64-NEXT: RET 0, implicit $eax
396 %0(s1) = G_IMPLICIT_DEF
397 %2(s32) = G_SEXT %0(s1)
403 name: test_sext_i8toi16
406 regBankSelected: false
408 - { id: 0, class: _, preferred-register: '' }
409 - { id: 1, class: _, preferred-register: '' }
414 ; X32-LABEL: name: test_sext_i8toi16
417 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
418 ; X32-NEXT: [[SEXT:%[0-9]+]]:_(s16) = G_SEXT [[COPY]](s8)
419 ; X32-NEXT: $ax = COPY [[SEXT]](s16)
420 ; X32-NEXT: RET 0, implicit $ax
422 ; X64-LABEL: name: test_sext_i8toi16
425 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
426 ; X64-NEXT: [[SEXT:%[0-9]+]]:_(s16) = G_SEXT [[COPY]](s8)
427 ; X64-NEXT: $ax = COPY [[SEXT]](s16)
428 ; X64-NEXT: RET 0, implicit $ax
430 %1(s16) = G_SEXT %0(s8)
439 regBankSelected: false
441 - { id: 0, class: _ }
442 - { id: 1, class: _ }
447 ; X32-LABEL: name: test_sext_i8
450 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
451 ; X32-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[COPY]](s8)
452 ; X32-NEXT: $eax = COPY [[SEXT]](s32)
453 ; X32-NEXT: RET 0, implicit $eax
455 ; X64-LABEL: name: test_sext_i8
458 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
459 ; X64-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[COPY]](s8)
460 ; X64-NEXT: $eax = COPY [[SEXT]](s32)
461 ; X64-NEXT: RET 0, implicit $eax
463 %1(s32) = G_SEXT %0(s8)
472 regBankSelected: false
474 - { id: 0, class: _ }
475 - { id: 1, class: _ }
480 ; X32-LABEL: name: test_sext_i16
483 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $di
484 ; X32-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[COPY]](s16)
485 ; X32-NEXT: $eax = COPY [[SEXT]](s32)
486 ; X32-NEXT: RET 0, implicit $eax
488 ; X64-LABEL: name: test_sext_i16
491 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $di
492 ; X64-NEXT: [[SEXT:%[0-9]+]]:_(s32) = G_SEXT [[COPY]](s16)
493 ; X64-NEXT: $eax = COPY [[SEXT]](s32)
494 ; X64-NEXT: RET 0, implicit $eax
496 %1(s32) = G_SEXT %0(s16)
502 name: test_anyext_i1toi8
505 regBankSelected: false
507 - { id: 0, class: _, preferred-register: '' }
508 - { id: 1, class: _, preferred-register: '' }
509 - { id: 2, class: _, preferred-register: '' }
514 ; X32-LABEL: name: test_anyext_i1toi8
517 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
518 ; X32-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
519 ; X32-NEXT: $al = COPY [[TRUNC]](s8)
520 ; X32-NEXT: RET 0, implicit $al
522 ; X64-LABEL: name: test_anyext_i1toi8
525 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
526 ; X64-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
527 ; X64-NEXT: $al = COPY [[TRUNC]](s8)
528 ; X64-NEXT: RET 0, implicit $al
530 %1(s1) = G_TRUNC %0(s32)
531 %2(s8) = G_ANYEXT %1(s1)
537 name: test_anyext_i1toi16
540 regBankSelected: false
542 - { id: 0, class: _, preferred-register: '' }
543 - { id: 1, class: _, preferred-register: '' }
544 - { id: 2, class: _, preferred-register: '' }
549 ; X32-LABEL: name: test_anyext_i1toi16
552 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
553 ; X32-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
554 ; X32-NEXT: $ax = COPY [[TRUNC]](s16)
555 ; X32-NEXT: RET 0, implicit $ax
557 ; X64-LABEL: name: test_anyext_i1toi16
560 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $edi
561 ; X64-NEXT: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[COPY]](s32)
562 ; X64-NEXT: $ax = COPY [[TRUNC]](s16)
563 ; X64-NEXT: RET 0, implicit $ax
565 %1(s1) = G_TRUNC %0(s32)
566 %2(s16) = G_ANYEXT %1(s1)
575 regBankSelected: false
577 - { id: 0, class: _ }
578 - { id: 1, class: _ }
579 - { id: 2, class: _ }
584 ; X32-LABEL: name: test_anyext_i1
587 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
588 ; X32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s8)
589 ; X32-NEXT: $eax = COPY [[ANYEXT]](s32)
590 ; X32-NEXT: RET 0, implicit $eax
592 ; X64-LABEL: name: test_anyext_i1
595 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
596 ; X64-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s8)
597 ; X64-NEXT: $eax = COPY [[ANYEXT]](s32)
598 ; X64-NEXT: RET 0, implicit $eax
600 %1(s1) = G_TRUNC %0(s8)
601 %2(s32) = G_ANYEXT %1(s1)
607 name: test_anyext_i8toi16
610 regBankSelected: false
612 - { id: 0, class: _, preferred-register: '' }
613 - { id: 1, class: _, preferred-register: '' }
618 ; X32-LABEL: name: test_anyext_i8toi16
621 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
622 ; X32-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[COPY]](s8)
623 ; X32-NEXT: $ax = COPY [[ANYEXT]](s16)
624 ; X32-NEXT: RET 0, implicit $ax
626 ; X64-LABEL: name: test_anyext_i8toi16
629 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
630 ; X64-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[COPY]](s8)
631 ; X64-NEXT: $ax = COPY [[ANYEXT]](s16)
632 ; X64-NEXT: RET 0, implicit $ax
634 %1(s16) = G_ANYEXT %0(s8)
643 regBankSelected: false
645 - { id: 0, class: _ }
646 - { id: 1, class: _ }
651 ; X32-LABEL: name: test_anyext_i8
654 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
655 ; X32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s8)
656 ; X32-NEXT: $eax = COPY [[ANYEXT]](s32)
657 ; X32-NEXT: RET 0, implicit $eax
659 ; X64-LABEL: name: test_anyext_i8
662 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY $dil
663 ; X64-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s8)
664 ; X64-NEXT: $eax = COPY [[ANYEXT]](s32)
665 ; X64-NEXT: RET 0, implicit $eax
667 %1(s32) = G_ANYEXT %0(s8)
673 name: test_anyext_i16
676 regBankSelected: false
678 - { id: 0, class: _ }
679 - { id: 1, class: _ }
684 ; X32-LABEL: name: test_anyext_i16
687 ; X32-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $di
688 ; X32-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s16)
689 ; X32-NEXT: $eax = COPY [[ANYEXT]](s32)
690 ; X32-NEXT: RET 0, implicit $eax
692 ; X64-LABEL: name: test_anyext_i16
695 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY $di
696 ; X64-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[COPY]](s16)
697 ; X64-NEXT: $eax = COPY [[ANYEXT]](s32)
698 ; X64-NEXT: RET 0, implicit $eax
700 %1(s32) = G_ANYEXT %0(s16)