1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-apple-darwin10 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=X32
3; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefix=X64
4
5define i8 @test1(i8 %x) nounwind {
6; X32-LABEL: test1:
7; X32:       ## %bb.0:
8; X32-NEXT:    movb {{[0-9]+}}(%esp), %al
9; X32-NEXT:    andb $1, %al
10; X32-NEXT:    negb %al
11; X32-NEXT:    retl
12;
13; X64-LABEL: test1:
14; X64:       ## %bb.0:
15; X64-NEXT:    movl %edi, %eax
16; X64-NEXT:    andb $1, %al
17; X64-NEXT:    negb %al
18; X64-NEXT:    ## kill: def $al killed $al killed $eax
19; X64-NEXT:    retq
20  %z = trunc i8 %x to i1
21  %u = sext i1 %z to i8
22  ret i8 %u
23}
24
25define i16 @test2(i16 %x) nounwind {
26; X32-LABEL: test2:
27; X32:       ## %bb.0:
28; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
29; X32-NEXT:    andb $1, %al
30; X32-NEXT:    negb %al
31; X32-NEXT:    movsbl %al, %eax
32; X32-NEXT:    ## kill: def $ax killed $ax killed $eax
33; X32-NEXT:    retl
34;
35; X64-LABEL: test2:
36; X64:       ## %bb.0:
37; X64-NEXT:    andb $1, %dil
38; X64-NEXT:    negb %dil
39; X64-NEXT:    movsbl %dil, %eax
40; X64-NEXT:    ## kill: def $ax killed $ax killed $eax
41; X64-NEXT:    retq
42  %z = trunc i16 %x to i1
43  %u = sext i1 %z to i16
44  ret i16 %u
45}
46
47define i32 @test3(i32 %x) nounwind {
48; X32-LABEL: test3:
49; X32:       ## %bb.0:
50; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
51; X32-NEXT:    andb $1, %al
52; X32-NEXT:    negb %al
53; X32-NEXT:    movsbl %al, %eax
54; X32-NEXT:    retl
55;
56; X64-LABEL: test3:
57; X64:       ## %bb.0:
58; X64-NEXT:    andb $1, %dil
59; X64-NEXT:    negb %dil
60; X64-NEXT:    movsbl %dil, %eax
61; X64-NEXT:    retq
62  %z = trunc i32 %x to i1
63  %u = sext i1 %z to i32
64  ret i32 %u
65}
66
67define i32 @test4(i32 %x) nounwind {
68; X32-LABEL: test4:
69; X32:       ## %bb.0:
70; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
71; X32-NEXT:    andb $1, %al
72; X32-NEXT:    negb %al
73; X32-NEXT:    movsbl %al, %eax
74; X32-NEXT:    retl
75;
76; X64-LABEL: test4:
77; X64:       ## %bb.0:
78; X64-NEXT:    andb $1, %dil
79; X64-NEXT:    negb %dil
80; X64-NEXT:    movsbl %dil, %eax
81; X64-NEXT:    retq
82  %z = trunc i32 %x to i1
83  %u = sext i1 %z to i32
84  ret i32 %u
85}
86
87define i8 @test5(i8 %x) nounwind {
88; X32-LABEL: test5:
89; X32:       ## %bb.0:
90; X32-NEXT:    movb {{[0-9]+}}(%esp), %al
91; X32-NEXT:    andb $1, %al
92; X32-NEXT:    retl
93;
94; X64-LABEL: test5:
95; X64:       ## %bb.0:
96; X64-NEXT:    movl %edi, %eax
97; X64-NEXT:    andb $1, %al
98; X64-NEXT:    ## kill: def $al killed $al killed $eax
99; X64-NEXT:    retq
100  %z = trunc i8 %x to i1
101  %u = zext i1 %z to i8
102  ret i8 %u
103}
104
105define i16 @test6(i16 %x) nounwind {
106; X32-LABEL: test6:
107; X32:       ## %bb.0:
108; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
109; X32-NEXT:    andb $1, %al
110; X32-NEXT:    movzbl %al, %eax
111; X32-NEXT:    ## kill: def $ax killed $ax killed $eax
112; X32-NEXT:    retl
113;
114; X64-LABEL: test6:
115; X64:       ## %bb.0:
116; X64-NEXT:    andb $1, %dil
117; X64-NEXT:    movzbl %dil, %eax
118; X64-NEXT:    ## kill: def $ax killed $ax killed $eax
119; X64-NEXT:    retq
120  %z = trunc i16 %x to i1
121  %u = zext i1 %z to i16
122  ret i16 %u
123}
124
125define i32 @test7(i32 %x) nounwind {
126; X32-LABEL: test7:
127; X32:       ## %bb.0:
128; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
129; X32-NEXT:    andb $1, %al
130; X32-NEXT:    movzbl %al, %eax
131; X32-NEXT:    retl
132;
133; X64-LABEL: test7:
134; X64:       ## %bb.0:
135; X64-NEXT:    andb $1, %dil
136; X64-NEXT:    movzbl %dil, %eax
137; X64-NEXT:    retq
138  %z = trunc i32 %x to i1
139  %u = zext i1 %z to i32
140  ret i32 %u
141}
142
143define i32 @test8(i32 %x) nounwind {
144; X32-LABEL: test8:
145; X32:       ## %bb.0:
146; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
147; X32-NEXT:    andb $1, %al
148; X32-NEXT:    movzbl %al, %eax
149; X32-NEXT:    retl
150;
151; X64-LABEL: test8:
152; X64:       ## %bb.0:
153; X64-NEXT:    andb $1, %dil
154; X64-NEXT:    movzbl %dil, %eax
155; X64-NEXT:    retq
156  %z = trunc i32 %x to i1
157  %u = zext i1 %z to i32
158  ret i32 %u
159}
160
161define i16 @test9(i8 %x) nounwind {
162; X32-LABEL: test9:
163; X32:       ## %bb.0:
164; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
165; X32-NEXT:    ## kill: def $ax killed $ax killed $eax
166; X32-NEXT:    retl
167;
168; X64-LABEL: test9:
169; X64:       ## %bb.0:
170; X64-NEXT:    movsbl %dil, %eax
171; X64-NEXT:    ## kill: def $ax killed $ax killed $eax
172; X64-NEXT:    retq
173  %u = sext i8 %x to i16
174  ret i16 %u
175}
176
177define i32 @test10(i8 %x) nounwind {
178; X32-LABEL: test10:
179; X32:       ## %bb.0:
180; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
181; X32-NEXT:    retl
182;
183; X64-LABEL: test10:
184; X64:       ## %bb.0:
185; X64-NEXT:    movsbl %dil, %eax
186; X64-NEXT:    retq
187  %u = sext i8 %x to i32
188  ret i32 %u
189}
190
191define i64 @test11(i8 %x) nounwind {
192; X32-LABEL: test11:
193; X32:       ## %bb.0:
194; X32-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
195; X32-NEXT:    movl %eax, %edx
196; X32-NEXT:    sarl $31, %edx
197; X32-NEXT:    retl
198;
199; X64-LABEL: test11:
200; X64:       ## %bb.0:
201; X64-NEXT:    movsbq %dil, %rax
202; X64-NEXT:    retq
203  %u = sext i8 %x to i64
204  ret i64 %u
205}
206
207define i16 @test12(i8 %x) nounwind {
208; X32-LABEL: test12:
209; X32:       ## %bb.0:
210; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
211; X32-NEXT:    ## kill: def $ax killed $ax killed $eax
212; X32-NEXT:    retl
213;
214; X64-LABEL: test12:
215; X64:       ## %bb.0:
216; X64-NEXT:    movzbl %dil, %eax
217; X64-NEXT:    ## kill: def $ax killed $ax killed $eax
218; X64-NEXT:    retq
219  %u = zext i8 %x to i16
220  ret i16 %u
221}
222
223define i32 @test13(i8 %x) nounwind {
224; X32-LABEL: test13:
225; X32:       ## %bb.0:
226; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
227; X32-NEXT:    retl
228;
229; X64-LABEL: test13:
230; X64:       ## %bb.0:
231; X64-NEXT:    movzbl %dil, %eax
232; X64-NEXT:    retq
233  %u = zext i8 %x to i32
234  ret i32 %u
235}
236
237define i64 @test14(i8 %x) nounwind {
238; X32-LABEL: test14:
239; X32:       ## %bb.0:
240; X32-NEXT:    movzbl {{[0-9]+}}(%esp), %eax
241; X32-NEXT:    xorl %edx, %edx
242; X32-NEXT:    retl
243;
244; X64-LABEL: test14:
245; X64:       ## %bb.0:
246; X64-NEXT:    movzbl %dil, %eax
247; X64-NEXT:    retq
248  %u = zext i8 %x to i64
249  ret i64 %u
250}
251
252define i32 @test15(i16 %x) nounwind {
253; X32-LABEL: test15:
254; X32:       ## %bb.0:
255; X32-NEXT:    movswl {{[0-9]+}}(%esp), %eax
256; X32-NEXT:    retl
257;
258; X64-LABEL: test15:
259; X64:       ## %bb.0:
260; X64-NEXT:    movswl %di, %eax
261; X64-NEXT:    retq
262  %u = sext i16 %x to i32
263  ret i32 %u
264}
265
266define i64 @test16(i16 %x) nounwind {
267; X32-LABEL: test16:
268; X32:       ## %bb.0:
269; X32-NEXT:    movswl {{[0-9]+}}(%esp), %eax
270; X32-NEXT:    movl %eax, %edx
271; X32-NEXT:    sarl $31, %edx
272; X32-NEXT:    retl
273;
274; X64-LABEL: test16:
275; X64:       ## %bb.0:
276; X64-NEXT:    movswq %di, %rax
277; X64-NEXT:    retq
278  %u = sext i16 %x to i64
279  ret i64 %u
280}
281
282define i32 @test17(i16 %x) nounwind {
283; X32-LABEL: test17:
284; X32:       ## %bb.0:
285; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
286; X32-NEXT:    retl
287;
288; X64-LABEL: test17:
289; X64:       ## %bb.0:
290; X64-NEXT:    movzwl %di, %eax
291; X64-NEXT:    retq
292  %u = zext i16 %x to i32
293  ret i32 %u
294}
295
296define i64 @test18(i16 %x) nounwind {
297; X32-LABEL: test18:
298; X32:       ## %bb.0:
299; X32-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
300; X32-NEXT:    xorl %edx, %edx
301; X32-NEXT:    retl
302;
303; X64-LABEL: test18:
304; X64:       ## %bb.0:
305; X64-NEXT:    movzwl %di, %eax
306; X64-NEXT:    retq
307  %u = zext i16 %x to i64
308  ret i64 %u
309}
310
311define i64 @test19(i32 %x) nounwind {
312; X32-LABEL: test19:
313; X32:       ## %bb.0:
314; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
315; X32-NEXT:    movl %eax, %edx
316; X32-NEXT:    sarl $31, %edx
317; X32-NEXT:    retl
318;
319; X64-LABEL: test19:
320; X64:       ## %bb.0:
321; X64-NEXT:    movslq %edi, %rax
322; X64-NEXT:    retq
323  %u = sext i32 %x to i64
324  ret i64 %u
325}
326
327define i64 @test20(i32 %x) nounwind {
328; X32-LABEL: test20:
329; X32:       ## %bb.0:
330; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
331; X32-NEXT:    xorl %edx, %edx
332; X32-NEXT:    retl
333;
334; X64-LABEL: test20:
335; X64:       ## %bb.0:
336; X64-NEXT:    movl %edi, %eax
337; X64-NEXT:    retq
338  %u = zext i32 %x to i64
339  ret i64 %u
340}
341