1; RUN: llc -mcpu=generic -mtriple=i686-unknown-unknown < %s | FileCheck %s
2define i64 @test1(i32 %xx, i32 %test) nounwind {
3  %conv = zext i32 %xx to i64
4  %and = and i32 %test, 7
5  %sh_prom = zext i32 %and to i64
6  %shl = shl i64 %conv, %sh_prom
7  ret i64 %shl
8; CHECK-LABEL: test1:
9; CHECK: shll	%cl, %eax
10; CHECK: shrl	%edx
11; CHECK: xorb	$31
12; CHECK: shrl	%cl, %edx
13}
14
15define i64 @test2(i64 %xx, i32 %test) nounwind {
16  %and = and i32 %test, 7
17  %sh_prom = zext i32 %and to i64
18  %shl = shl i64 %xx, %sh_prom
19  ret i64 %shl
20; CHECK-LABEL: test2:
21; CHECK: shll	%cl, %esi
22; CHECK: shrl	%edx
23; CHECK: xorb	$31
24; CHECK: shrl	%cl, %edx
25; CHECK: orl	%esi, %edx
26; CHECK: shll	%cl, %eax
27}
28
29define i64 @test3(i64 %xx, i32 %test) nounwind {
30  %and = and i32 %test, 7
31  %sh_prom = zext i32 %and to i64
32  %shr = lshr i64 %xx, %sh_prom
33  ret i64 %shr
34; CHECK-LABEL: test3:
35; CHECK: shrl	%cl, %esi
36; CHECK: leal	(%edx,%edx), %eax
37; CHECK: xorb	$31, %cl
38; CHECK: shll	%cl, %eax
39; CHECK: orl	%esi, %eax
40; CHECK: shrl	%cl, %edx
41}
42
43define i64 @test4(i64 %xx, i32 %test) nounwind {
44  %and = and i32 %test, 7
45  %sh_prom = zext i32 %and to i64
46  %shr = ashr i64 %xx, %sh_prom
47  ret i64 %shr
48; CHECK-LABEL: test4:
49; CHECK: shrl	%cl, %esi
50; CHECK: leal	(%edx,%edx), %eax
51; CHECK: xorb	$31, %cl
52; CHECK: shll	%cl, %eax
53; CHECK: orl	%esi, %eax
54; CHECK: sarl	%cl, %edx
55}
56
57; PR14668
58define <2 x i64> @test5(<2 x i64> %A, <2 x i64> %B) {
59  %shl = shl <2 x i64> %A, %B
60  ret <2 x i64> %shl
61; CHECK: test5
62; CHECK: shl
63; CHECK: shldl
64; CHECK: shl
65; CHECK: shldl
66}
67
68; PR16108
69define i32 @test6() {
70  %x = alloca i32, align 4
71  %t = alloca i64, align 8
72  store i32 1, i32* %x, align 4
73  store i64 1, i64* %t, align 8  ;; DEAD
74  %load = load i32, i32* %x, align 4
75  %shl = shl i32 %load, 8
76  %add = add i32 %shl, -224
77  %sh_prom = zext i32 %add to i64
78  %shl1 = shl i64 1, %sh_prom
79  %cmp = icmp ne i64 %shl1, 4294967296
80  br i1 %cmp, label %if.then, label %if.end
81
82if.then:                                          ; preds = %entry
83  ret i32 1
84
85if.end:                                           ; preds = %entry
86  ret i32 0
87
88; CHECK-LABEL: test6:
89; CHECK-NOT: andb $31
90; CHECK: sete
91; CHECK: movzbl
92; CHECK: xorl $1
93; CHECK: orl
94}
95