1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=x86_64-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X64 3; RUN: llc -mtriple=i386-linux-gnu -global-isel -verify-machineinstrs < %s -o - | FileCheck %s --check-prefix=X32 4 5define i8 @test_zext_i1toi8(i32 %a) { 6; X64-LABEL: test_zext_i1toi8: 7; X64: # %bb.0: 8; X64-NEXT: andb $1, %dil 9; X64-NEXT: movl %edi, %eax 10; X64-NEXT: retq 11; 12; X32-LABEL: test_zext_i1toi8: 13; X32: # %bb.0: 14; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 15; X32-NEXT: andb $1, %al 16; X32-NEXT: # kill: def $al killed $al killed $eax 17; X32-NEXT: retl 18 %val = trunc i32 %a to i1 19 %r = zext i1 %val to i8 20 ret i8 %r 21} 22 23define i16 @test_zext_i1toi16(i32 %a) { 24; X64-LABEL: test_zext_i1toi16: 25; X64: # %bb.0: 26; X64-NEXT: andw $1, %di 27; X64-NEXT: movl %edi, %eax 28; X64-NEXT: retq 29; 30; X32-LABEL: test_zext_i1toi16: 31; X32: # %bb.0: 32; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 33; X32-NEXT: andw $1, %ax 34; X32-NEXT: # kill: def $ax killed $ax killed $eax 35; X32-NEXT: retl 36 %val = trunc i32 %a to i1 37 %r = zext i1 %val to i16 38 ret i16 %r 39} 40 41define i32 @test_zext_i1(i32 %a) { 42; X64-LABEL: test_zext_i1: 43; X64: # %bb.0: 44; X64-NEXT: andl $1, %edi 45; X64-NEXT: movl %edi, %eax 46; X64-NEXT: retq 47; 48; X32-LABEL: test_zext_i1: 49; X32: # %bb.0: 50; X32-NEXT: movl {{[0-9]+}}(%esp), %eax 51; X32-NEXT: andl $1, %eax 52; X32-NEXT: retl 53 %val = trunc i32 %a to i1 54 %r = zext i1 %val to i32 55 ret i32 %r 56} 57 58define i32 @test_zext_i8(i8 %val) { 59; X64-LABEL: test_zext_i8: 60; X64: # %bb.0: 61; X64-NEXT: movzbl %dil, %eax 62; X64-NEXT: retq 63; 64; X32-LABEL: test_zext_i8: 65; X32: # %bb.0: 66; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax 67; X32-NEXT: retl 68 %r = zext i8 %val to i32 69 ret i32 %r 70} 71 72define i32 @test_zext_i16(i16 %val) { 73; X64-LABEL: test_zext_i16: 74; X64: # %bb.0: 75; X64-NEXT: movzwl %di, %eax 76; X64-NEXT: retq 77; 78; X32-LABEL: test_zext_i16: 79; X32: # %bb.0: 80; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax 81; X32-NEXT: retl 82 %r = zext i16 %val to i32 83 ret i32 %r 84} 85 86define i32 @test_sext_i8(i8 %val) { 87; X64-LABEL: test_sext_i8: 88; X64: # %bb.0: 89; X64-NEXT: movl $24, %ecx 90; X64-NEXT: # kill: def $cl killed $ecx 91; X64-NEXT: shll %cl, %edi 92; X64-NEXT: movl $24, %ecx 93; X64-NEXT: # kill: def $cl killed $ecx 94; X64-NEXT: sarl %cl, %edi 95; X64-NEXT: movl %edi, %eax 96; X64-NEXT: retq 97; 98; X32-LABEL: test_sext_i8: 99; X32: # %bb.0: 100; X32-NEXT: movsbl {{[0-9]+}}(%esp), %eax 101; X32-NEXT: retl 102 %r = sext i8 %val to i32 103 ret i32 %r 104} 105 106define i32 @test_sext_i16(i16 %val) { 107; X64-LABEL: test_sext_i16: 108; X64: # %bb.0: 109; X64-NEXT: movl $16, %ecx 110; X64-NEXT: # kill: def $cl killed $ecx 111; X64-NEXT: shll %cl, %edi 112; X64-NEXT: movl $16, %ecx 113; X64-NEXT: # kill: def $cl killed $ecx 114; X64-NEXT: sarl %cl, %edi 115; X64-NEXT: movl %edi, %eax 116; X64-NEXT: retq 117; 118; X32-LABEL: test_sext_i16: 119; X32: # %bb.0: 120; X32-NEXT: movswl {{[0-9]+}}(%esp), %eax 121; X32-NEXT: retl 122 %r = sext i16 %val to i32 123 ret i32 %r 124} 125 126