• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:    movl %edi, %eax
9; X64-NEXT:    andb $1, %al
10; X64-NEXT:    # kill: def $al killed $al killed $eax
11; X64-NEXT:    retq
12;
13; X32-LABEL: test_zext_i1toi8:
14; X32:       # %bb.0:
15; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
16; X32-NEXT:    andb $1, %al
17; X32-NEXT:    # kill: def $al killed $al killed $eax
18; X32-NEXT:    retl
19  %val = trunc i32 %a to i1
20  %r = zext i1 %val to i8
21  ret i8 %r
22}
23
24define i16 @test_zext_i1toi16(i32 %a) {
25; X64-LABEL: test_zext_i1toi16:
26; X64:       # %bb.0:
27; X64-NEXT:    movl %edi, %eax
28; X64-NEXT:    andw $1, %ax
29; X64-NEXT:    # kill: def $ax killed $ax killed $eax
30; X64-NEXT:    retq
31;
32; X32-LABEL: test_zext_i1toi16:
33; X32:       # %bb.0:
34; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
35; X32-NEXT:    andw $1, %ax
36; X32-NEXT:    # kill: def $ax killed $ax killed $eax
37; X32-NEXT:    retl
38  %val = trunc i32 %a to i1
39  %r = zext i1 %val to i16
40  ret i16 %r
41}
42
43define i32 @test_zext_i1(i32 %a) {
44; X64-LABEL: test_zext_i1:
45; X64:       # %bb.0:
46; X64-NEXT:    movl %edi, %eax
47; X64-NEXT:    andl $1, %eax
48; X64-NEXT:    retq
49;
50; X32-LABEL: test_zext_i1:
51; X32:       # %bb.0:
52; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
53; X32-NEXT:    andl $1, %eax
54; X32-NEXT:    retl
55  %val = trunc i32 %a to i1
56  %r = zext i1 %val to i32
57  ret i32 %r
58}
59
60define i32 @test_zext_i8(i8 %val) {
61; X64-LABEL: test_zext_i8:
62; X64:       # %bb.0:
63; X64-NEXT:    movzbl %dil, %eax
64; X64-NEXT:    retq
65;
66; X32-LABEL: test_zext_i8:
67; X32:       # %bb.0:
68; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
69; X32-NEXT:    retl
70  %r = zext i8 %val to i32
71  ret i32 %r
72}
73
74define i32 @test_zext_i16(i16 %val) {
75; X64-LABEL: test_zext_i16:
76; X64:       # %bb.0:
77; X64-NEXT:    movzwl %di, %eax
78; X64-NEXT:    retq
79;
80; X32-LABEL: test_zext_i16:
81; X32:       # %bb.0:
82; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
83; X32-NEXT:    retl
84  %r = zext i16 %val to i32
85  ret i32 %r
86}
87
88define i32 @test_sext_i8(i8 %val) {
89; X64-LABEL: test_sext_i8:
90; X64:       # %bb.0:
91; X64-NEXT:    movl %edi, %eax
92; X64-NEXT:    shll $24, %eax
93; X64-NEXT:    sarl $24, %eax
94; X64-NEXT:    retq
95;
96; X32-LABEL: test_sext_i8:
97; X32:       # %bb.0:
98; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
99; X32-NEXT:    retl
100  %r = sext i8 %val to i32
101  ret i32 %r
102}
103
104define i32 @test_sext_i16(i16 %val) {
105; X64-LABEL: test_sext_i16:
106; X64:       # %bb.0:
107; X64-NEXT:    movl %edi, %eax
108; X64-NEXT:    shll $16, %eax
109; X64-NEXT:    sarl $16, %eax
110; X64-NEXT:    retq
111;
112; X32-LABEL: test_sext_i16:
113; X32:       # %bb.0:
114; X32-NEXT:    movswl {{[0-9]+}}(%esp), %eax
115; X32-NEXT:    retl
116  %r = sext i16 %val to i32
117  ret i32 %r
118}
119
120define i16 @test_zext_i8_to_i16(i8 %x, i8 %y) {
121; X64-LABEL: test_zext_i8_to_i16:
122; X64:       # %bb.0:
123; X64-NEXT:    addb %dil, %sil
124; X64-NEXT:    movzbl %sil, %eax
125; X64-NEXT:    # kill: def $ax killed $ax killed $eax
126; X64-NEXT:    retq
127;
128; X32-LABEL: test_zext_i8_to_i16:
129; X32:       # %bb.0:
130; X32-NEXT:    movb {{[0-9]+}}(%esp), %al
131; X32-NEXT:    addb {{[0-9]+}}(%esp), %al
132; X32-NEXT:    movzbl %al, %eax
133; X32-NEXT:    # kill: def $ax killed $ax killed $eax
134; X32-NEXT:    retl
135  %a = add i8 %x, %y
136  %b = zext i8 %a to i16
137  ret i16 %b
138}
139