1; RUN: llc < %s -march=x86-64 | FileCheck %s
2
3declare void @bar()
4
5define void @test1(i32* nocapture %X) nounwind minsize {
6entry:
7  %tmp1 = load i32, i32* %X, align 4
8  %and = and i32 %tmp1, 255
9  %cmp = icmp eq i32 %and, 47
10  br i1 %cmp, label %if.then, label %if.end
11
12if.then:
13  tail call void @bar() nounwind
14  br label %if.end
15
16if.end:
17  ret void
18; CHECK-LABEL: test1:
19; CHECK: cmpb $47, (%{{rdi|rcx}})
20}
21
22define void @test2(i32 %X) nounwind minsize {
23entry:
24  %and = and i32 %X, 255
25  %cmp = icmp eq i32 %and, 47
26  br i1 %cmp, label %if.then, label %if.end
27
28if.then:
29  tail call void @bar() nounwind
30  br label %if.end
31
32if.end:
33  ret void
34; CHECK-LABEL: test2:
35; CHECK: cmpb $47, %{{dil|cl}}
36}
37
38define void @test3(i32 %X) nounwind minsize {
39entry:
40  %and = and i32 %X, 255
41  %cmp = icmp eq i32 %and, 255
42  br i1 %cmp, label %if.then, label %if.end
43
44if.then:
45  tail call void @bar() nounwind
46  br label %if.end
47
48if.end:
49  ret void
50; CHECK-LABEL: test3:
51; CHECK: cmpb $-1, %{{dil|cl}}
52}
53
54; PR16083
55define i1 @test4(i64 %a, i32 %b) {
56entry:
57  %tobool = icmp ne i32 %b, 0
58  br i1 %tobool, label %lor.end, label %lor.rhs
59
60lor.rhs:                                          ; preds = %entry
61  %and = and i64 0, %a
62  %tobool1 = icmp ne i64 %and, 0
63  br label %lor.end
64
65lor.end:                                          ; preds = %lor.rhs, %entry
66  %p = phi i1 [ true, %entry ], [ %tobool1, %lor.rhs ]
67  ret i1 %p
68}
69
70@x = global { i8, i8, i8, i8, i8, i8, i8, i8 } { i8 1, i8 0, i8 0, i8 0, i8 1, i8 0, i8 0, i8 1 }, align 4
71
72; PR16551
73define void @test5(i32 %X) nounwind minsize {
74entry:
75  %bf.load = load i56, i56* bitcast ({ i8, i8, i8, i8, i8, i8, i8, i8 }* @x to i56*), align 4
76  %bf.lshr = lshr i56 %bf.load, 32
77  %bf.cast = trunc i56 %bf.lshr to i32
78  %cmp = icmp ne i32 %bf.cast, 1
79  br i1 %cmp, label %if.then, label %if.end
80
81if.then:
82  tail call void @bar() nounwind
83  br label %if.end
84
85if.end:
86  ret void
87
88; CHECK-LABEL: test5:
89; CHECK-NOT: cmpl $1,{{.*}}x+4
90; CHECK: ret
91}
92
93; CHECK-LABEL: test2_1:
94; CHECK: movzbl
95; CHECK: cmpl $256
96; CHECK: jne
97define void @test2_1(i32 %X) nounwind minsize {
98entry:
99  %and = and i32 %X, 255
100  %cmp = icmp eq i32 %and, 256
101  br i1 %cmp, label %if.then, label %if.end
102
103if.then:
104  tail call void @bar() nounwind
105  br label %if.end
106
107if.end:
108  ret void
109}
110
111; CHECK-LABEL: test_sext_i8_icmp_1:
112; CHECK: cmpb $1, %{{dil|cl}}
113define void @test_sext_i8_icmp_1(i8 %x) nounwind minsize {
114entry:
115  %sext = sext i8 %x to i32
116  %cmp = icmp eq i32 %sext, 1
117  br i1 %cmp, label %if.then, label %if.end
118
119if.then:
120  tail call void @bar() nounwind
121  br label %if.end
122
123if.end:
124  ret void
125}
126
127; CHECK-LABEL: test_sext_i8_icmp_47:
128; CHECK: cmpb $47, %{{dil|cl}}
129define void @test_sext_i8_icmp_47(i8 %x) nounwind minsize {
130entry:
131  %sext = sext i8 %x to i32
132  %cmp = icmp eq i32 %sext, 47
133  br i1 %cmp, label %if.then, label %if.end
134
135if.then:
136  tail call void @bar() nounwind
137  br label %if.end
138
139if.end:
140  ret void
141}
142
143; CHECK-LABEL: test_sext_i8_icmp_127:
144; CHECK: cmpb $127, %{{dil|cl}}
145define void @test_sext_i8_icmp_127(i8 %x) nounwind minsize {
146entry:
147  %sext = sext i8 %x to i32
148  %cmp = icmp eq i32 %sext, 127
149  br i1 %cmp, label %if.then, label %if.end
150
151if.then:
152  tail call void @bar() nounwind
153  br label %if.end
154
155if.end:
156  ret void
157}
158
159; CHECK-LABEL: test_sext_i8_icmp_neg1:
160; CHECK: cmpb $-1, %{{dil|cl}}
161define void @test_sext_i8_icmp_neg1(i8 %x) nounwind minsize {
162entry:
163  %sext = sext i8 %x to i32
164  %cmp = icmp eq i32 %sext, -1
165  br i1 %cmp, label %if.then, label %if.end
166
167if.then:
168  tail call void @bar() nounwind
169  br label %if.end
170
171if.end:
172  ret void
173}
174
175; CHECK-LABEL: test_sext_i8_icmp_neg2:
176; CHECK: cmpb $-2, %{{dil|cl}}
177define void @test_sext_i8_icmp_neg2(i8 %x) nounwind minsize {
178entry:
179  %sext = sext i8 %x to i32
180  %cmp = icmp eq i32 %sext, -2
181  br i1 %cmp, label %if.then, label %if.end
182
183if.then:
184  tail call void @bar() nounwind
185  br label %if.end
186
187if.end:
188  ret void
189}
190
191; CHECK-LABEL: test_sext_i8_icmp_neg127:
192; CHECK: cmpb $-127, %{{dil|cl}}
193define void @test_sext_i8_icmp_neg127(i8 %x) nounwind minsize {
194entry:
195  %sext = sext i8 %x to i32
196  %cmp = icmp eq i32 %sext, -127
197  br i1 %cmp, label %if.then, label %if.end
198
199if.then:
200  tail call void @bar() nounwind
201  br label %if.end
202
203if.end:
204  ret void
205}
206
207; CHECK-LABEL: test_sext_i8_icmp_neg128:
208; CHECK: cmpb $-128, %{{dil|cl}}
209define void @test_sext_i8_icmp_neg128(i8 %x) nounwind minsize {
210entry:
211  %sext = sext i8 %x to i32
212  %cmp = icmp eq i32 %sext, -128
213  br i1 %cmp, label %if.then, label %if.end
214
215if.then:
216  tail call void @bar() nounwind
217  br label %if.end
218
219if.end:
220  ret void
221}
222
223; CHECK-LABEL: test_sext_i8_icmp_255:
224; CHECK: movb $1,
225; CHECK: testb
226; CHECK: jne
227define void @test_sext_i8_icmp_255(i8 %x) nounwind minsize {
228entry:
229  %sext = sext i8 %x to i32
230  %cmp = icmp eq i32 %sext, 255
231  br i1 %cmp, label %if.then, label %if.end
232
233if.then:
234  tail call void @bar() nounwind
235  br label %if.end
236
237if.end:
238  ret void
239}
240