1 # RUN: llc -mtriple=i386-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X32
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=ALL --check-prefix=X64
5 define i8 @test_zext_i1toi8(i1 %a) {
10 define i16 @test_zext_i1toi16(i1 %a) {
11 %r = zext i1 %a to i16
15 define i32 @test_zext_i1(i1 %a) {
16 %r = zext i1 %a to i32
20 define i32 @test_zext_i8(i8 %val) {
21 %r = zext i8 %val to i32
25 define i32 @test_zext_i16(i16 %val) {
26 %r = zext i16 %val to i32
30 define i32 @test_sext_i8(i8 %val) {
31 %r = sext i8 %val to i32
35 define i32 @test_sext_i16(i16 %val) {
36 %r = sext i16 %val to i32
40 define void @test_anyext_i1toi8() { ret void }
41 define void @test_anyext_i1toi16() { ret void }
42 define void @test_anyext_i1toi32() { ret void }
43 define void @test_anyext_i8toi16() { ret void }
44 define void @test_anyext_i8toi32() { ret void }
45 define void @test_anyext_i16toi32() { ret void }
49 name: test_zext_i1toi8
50 # ALL-LABEL: name: test_zext_i1toi8
55 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
56 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
57 # X32-NEXT: - { id: 2, class: gr8, preferred-register: '' }
60 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
61 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
62 # X64-NEXT: - { id: 2, class: gr8, preferred-register: '' }
64 - { id: 0, class: gpr, preferred-register: '' }
65 - { id: 1, class: gpr, preferred-register: '' }
66 - { id: 2, class: gpr, preferred-register: '' }
67 # X32: %0:gr32_abcd = COPY $edi
68 # X64: %0:gr32 = COPY $edi
69 # ALL_NEXT: %1:gr8 = COPY %0.sub_8bit
70 # ALL_NEXT: %2:gr8 = AND8ri %1, 1, implicit-def $eflags
71 # ALL_NEXT: $al = COPY %2
72 # ALL_NEXT: RET 0, implicit $al
78 %1(s1) = G_TRUNC %0(s32)
79 %2(s8) = G_ZEXT %1(s1)
85 name: test_zext_i1toi16
86 # ALL-LABEL: name: test_zext_i1toi16
91 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
92 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
93 # X32-NEXT: - { id: 2, class: gr16, preferred-register: '' }
94 # X32-NEXT: - { id: 3, class: gr16, preferred-register: '' }
97 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
98 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
99 # X64-NEXT: - { id: 2, class: gr16, preferred-register: '' }
100 # X64-NEXT: - { id: 3, class: gr16, preferred-register: '' }
102 - { id: 0, class: gpr, preferred-register: '' }
103 - { id: 1, class: gpr, preferred-register: '' }
104 - { id: 2, class: gpr, preferred-register: '' }
105 # X32: %0:gr32_abcd = COPY $edi
106 # X64: %0:gr32 = COPY $edi
107 # ALL_NEXT: %1:gr8 = COPY %0.sub_8bit
108 # ALL_NEXT: %3:gr16 = SUBREG_TO_REG 0, %1, %subreg.sub_8bit
109 # ALL_NEXT: %2:gr16 = AND16ri8 %3, 1, implicit-def $eflags
110 # ALL_NEXT: $ax = COPY %2
111 # ALL_NEXT: RET 0, implicit $ax
117 %1(s1) = G_TRUNC %0(s32)
118 %2(s16) = G_ZEXT %1(s1)
125 # ALL-LABEL: name: test_zext_i1
128 regBankSelected: true
130 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
131 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
132 # X32-NEXT: - { id: 2, class: gr32, preferred-register: '' }
133 # X32-NEXT: - { id: 3, class: gr32, preferred-register: '' }
136 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
137 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
138 # X64-NEXT: - { id: 2, class: gr32, preferred-register: '' }
139 # X64-NEXT: - { id: 3, class: gr32, preferred-register: '' }
141 - { id: 0, class: gpr }
142 - { id: 1, class: gpr }
143 - { id: 2, class: gpr }
144 # X32: %0:gr32_abcd = COPY $edi
145 # X64: %0:gr32 = COPY $edi
146 # ALL_NEXT: %1:gr8 = COPY %0.sub_8bit
147 # ALL_NEXT: %3:gr32 = SUBREG_TO_REG 0, %1, %subreg.sub_8bit
148 # ALL_NEXT: %2:gr32 = AND32ri8 %3, 1, implicit-def $eflags
149 # ALL_NEXT: $eax = COPY %2
150 # ALL_NEXT: RET 0, implicit $eax
156 %1(s1) = G_TRUNC %0(s32)
157 %2(s32) = G_ZEXT %1(s1)
164 # ALL-LABEL: name: test_zext_i8
167 regBankSelected: true
169 # ALL-NEXT: - { id: 0, class: gr8, preferred-register: '' }
170 # ALL-NEXT: - { id: 1, class: gr32, preferred-register: '' }
172 - { id: 0, class: gpr }
173 - { id: 1, class: gpr }
174 # ALL: %0:gr8 = COPY $dil
175 # ALL-NEXT: %1:gr32 = MOVZX32rr8 %0
176 # ALL-NEXT: $eax = COPY %1
177 # ALL-NEXT: RET 0, implicit $eax
183 %1(s32) = G_ZEXT %0(s8)
190 # ALL-LABEL: name: test_zext_i16
193 regBankSelected: true
195 # ALL-NEXT: - { id: 0, class: gr16, preferred-register: '' }
196 # ALL-NEXT: - { id: 1, class: gr32, preferred-register: '' }
198 - { id: 0, class: gpr }
199 - { id: 1, class: gpr }
200 # ALL: %0:gr16 = COPY $di
201 # ALL-NEXT: %1:gr32 = MOVZX32rr16 %0
202 # ALL-NEXT: $eax = COPY %1
203 # ALL-NEXT: RET 0, implicit $eax
209 %1(s32) = G_ZEXT %0(s16)
216 # ALL-LABEL: name: test_sext_i8
219 regBankSelected: true
221 # ALL-NEXT: - { id: 0, class: gr8, preferred-register: '' }
222 # ALL-NEXT: - { id: 1, class: gr32, preferred-register: '' }
224 - { id: 0, class: gpr }
225 - { id: 1, class: gpr }
226 # ALL: %0:gr8 = COPY $dil
227 # ALL-NEXT: %1:gr32 = MOVSX32rr8 %0
228 # ALL-NEXT: $eax = COPY %1
229 # ALL-NEXT: RET 0, implicit $eax
235 %1(s32) = G_SEXT %0(s8)
242 # ALL-LABEL: name: test_sext_i16
245 regBankSelected: true
247 # ALL-NEXT: - { id: 0, class: gr16, preferred-register: '' }
248 # ALL-NEXT: - { id: 1, class: gr32, preferred-register: '' }
250 - { id: 0, class: gpr }
251 - { id: 1, class: gpr }
252 # ALL: %0:gr16 = COPY $di
253 # ALL-NEXT: %1:gr32 = MOVSX32rr16 %0
254 # ALL-NEXT: $eax = COPY %1
255 # ALL-NEXT: RET 0, implicit $eax
261 %1(s32) = G_SEXT %0(s16)
267 name: test_anyext_i1toi8
268 # ALL-LABEL: name: test_anyext_i1toi8
271 regBankSelected: true
273 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
274 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
275 # X32-NEXT: - { id: 2, class: gr8, preferred-register: '' }
278 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
279 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
280 # X64-NEXT: - { id: 2, class: gr8, preferred-register: '' }
282 - { id: 0, class: gpr }
283 - { id: 1, class: gpr }
284 - { id: 2, class: gpr }
285 # X32: %0:gr32_abcd = COPY $edi
286 # X64: %0:gr32 = COPY $edi
287 # ALL-NEXT: %1:gr8 = COPY %0.sub_8bit
288 # ALL-NEXT: $al = COPY %1
289 # ALL-NEXT: RET 0, implicit $al
295 %1(s1) = G_TRUNC %0(s32)
296 %2(s8) = G_ANYEXT %1(s1)
301 name: test_anyext_i1toi16
302 # ALL-LABEL: name: test_anyext_i1toi16
305 regBankSelected: true
307 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
308 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
309 # X32-NEXT: - { id: 2, class: gr16, preferred-register: '' }
312 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
313 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
314 # X64-NEXT: - { id: 2, class: gr16, preferred-register: '' }
316 - { id: 0, class: gpr }
317 - { id: 1, class: gpr }
318 - { id: 2, class: gpr }
319 # X32: %0:gr32_abcd = COPY $edi
320 # X64: %0:gr32 = COPY $edi
321 # ALL-NEXT: %1:gr8 = COPY %0.sub_8bit
322 # ALL-NEXT: %2:gr16 = SUBREG_TO_REG 0, %1, %subreg.sub_8bit
323 # ALL-NEXT: $ax = COPY %2
324 # ALL-NEXT: RET 0, implicit $ax
330 %1(s1) = G_TRUNC %0(s32)
331 %2(s16) = G_ANYEXT %1(s1)
336 name: test_anyext_i1toi32
337 # ALL-LABEL: name: test_anyext_i1toi32
340 regBankSelected: true
342 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
343 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
344 # X32-NEXT: - { id: 2, class: gr32, preferred-register: '' }
347 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
348 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
349 # X64-NEXT: - { id: 2, class: gr32, preferred-register: '' }
351 - { id: 0, class: gpr }
352 - { id: 1, class: gpr }
353 - { id: 2, class: gpr }
354 # X32: %0:gr32_abcd = COPY $edi
355 # X64: %0:gr32 = COPY $edi
356 # ALL-NEXT: %1:gr8 = COPY %0.sub_8bit
357 # ALL-NEXT: %2:gr32 = SUBREG_TO_REG 0, %1, %subreg.sub_8bit
358 # ALL-NEXT: $eax = COPY %2
359 # ALL-NEXT: RET 0, implicit $eax
365 %1(s1) = G_TRUNC %0(s32)
366 %2(s32) = G_ANYEXT %1(s1)
371 name: test_anyext_i8toi16
372 # ALL-LABEL: name: test_anyext_i8toi16
375 regBankSelected: true
377 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
378 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
379 # X32-NEXT: - { id: 2, class: gr16, preferred-register: '' }
382 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
383 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
384 # X64-NEXT: - { id: 2, class: gr16, preferred-register: '' }
386 - { id: 0, class: gpr }
387 - { id: 1, class: gpr }
388 - { id: 2, class: gpr }
389 # X32: %0:gr32_abcd = COPY $edi
390 # X64: %0:gr32 = COPY $edi
391 # ALL-NEXT: %1:gr8 = COPY %0.sub_8bit
392 # ALL-NEXT: %2:gr16 = SUBREG_TO_REG 0, %1, %subreg.sub_8bit
393 # ALL-NEXT: $ax = COPY %2
394 # ALL-NEXT: RET 0, implicit $ax
400 %1(s8) = G_TRUNC %0(s32)
401 %2(s16) = G_ANYEXT %1(s8)
406 name: test_anyext_i8toi32
407 # ALL-LABEL: name: test_anyext_i8toi32
410 regBankSelected: true
412 # X32-NEXT: - { id: 0, class: gr32_abcd, preferred-register: '' }
413 # X32-NEXT: - { id: 1, class: gr8, preferred-register: '' }
414 # X32-NEXT: - { id: 2, class: gr32, preferred-register: '' }
417 # X64-NEXT: - { id: 0, class: gr32, preferred-register: '' }
418 # X64-NEXT: - { id: 1, class: gr8, preferred-register: '' }
419 # X64-NEXT: - { id: 2, class: gr32, preferred-register: '' }
421 - { id: 0, class: gpr }
422 - { id: 1, class: gpr }
423 - { id: 2, class: gpr }
424 # X32: %0:gr32_abcd = COPY $edi
425 # X64: %0:gr32 = COPY $edi
426 # ALL-NEXT: %1:gr8 = COPY %0.sub_8bit
427 # ALL-NEXT: %2:gr32 = MOVZX32rr8 %1
428 # ALL-NEXT: $eax = COPY %2
429 # ALL-NEXT: RET 0, implicit $eax
435 %1(s8) = G_TRUNC %0(s32)
436 %2(s32) = G_ANYEXT %1(s8)
441 name: test_anyext_i16toi32
442 # ALL-LABEL: name: test_anyext_i16toi32
445 regBankSelected: true
447 # ALL-NEXT: - { id: 0, class: gr32, preferred-register: '' }
448 # ALL-NEXT: - { id: 1, class: gr16, preferred-register: '' }
449 # ALL-NEXT: - { id: 2, class: gr32, preferred-register: '' }
451 - { id: 0, class: gpr }
452 - { id: 1, class: gpr }
453 - { id: 2, class: gpr }
454 # ALL: %0:gr32 = COPY $edi
455 # ALL-NEXT: %1:gr16 = COPY %0.sub_16bit
456 # ALL-NEXT: %2:gr32 = SUBREG_TO_REG 0, %1, %subreg.sub_16bit
457 # ALL-NEXT: $eax = COPY %2
458 # ALL-NEXT: RET 0, implicit $eax
464 %1(s16) = G_TRUNC %0(s32)
465 %2(s32) = G_ANYEXT %1(s16)