1 ; RUN: llvm-as < %s | llc -march=x86 | grep btl | count 28
2 ; RUN: llvm-as < %s | llc -march=x86 -mcpu=pentium4 | grep btl | not grep esp
3 ; RUN: llvm-as < %s | llc -march=x86 -mcpu=penryn | grep btl | not grep esp
6 ; The register+memory form of the BT instruction should be usable on
7 ; pentium4, however it is currently disabled due to the register+memory
8 ; form having different semantics than the register+register form.
10 ; Test these patterns:
11 ; (X & (1 << N)) != 0 --> BT(X, N).
12 ; ((X >>u N) & 1) != 0 --> BT(X, N).
13 ; as well as several variations:
14 ; - The second form can use an arithmetic shift.
15 ; - Either form can use == instead of !=.
16 ; - Either form can compare with an operand of the &
18 ; - The comparison can be commuted (only cases where neither
19 ; operand is constant are included).
20 ; - The and can be commuted.
22 define void @test2(i32 %x, i32 %n) nounwind {
24 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
25 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
26 %tmp4 = icmp eq i32 %tmp3, 0 ; <i1> [#uses=1]
27 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
33 UnifiedReturnBlock: ; preds = %entry
37 define void @test2b(i32 %x, i32 %n) nounwind {
39 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
40 %tmp3 = and i32 1, %tmp29
41 %tmp4 = icmp eq i32 %tmp3, 0 ; <i1> [#uses=1]
42 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
48 UnifiedReturnBlock: ; preds = %entry
52 define void @atest2(i32 %x, i32 %n) nounwind {
54 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
55 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
56 %tmp4 = icmp eq i32 %tmp3, 0 ; <i1> [#uses=1]
57 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
63 UnifiedReturnBlock: ; preds = %entry
67 define void @atest2b(i32 %x, i32 %n) nounwind {
69 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
70 %tmp3 = and i32 1, %tmp29
71 %tmp4 = icmp eq i32 %tmp3, 0 ; <i1> [#uses=1]
72 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
78 UnifiedReturnBlock: ; preds = %entry
82 define void @test3(i32 %x, i32 %n) nounwind {
84 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
85 %tmp3 = and i32 %tmp29, %x ; <i32> [#uses=1]
86 %tmp4 = icmp eq i32 %tmp3, 0 ; <i1> [#uses=1]
87 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
93 UnifiedReturnBlock: ; preds = %entry
97 define void @test3b(i32 %x, i32 %n) nounwind {
99 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
100 %tmp3 = and i32 %x, %tmp29
101 %tmp4 = icmp eq i32 %tmp3, 0 ; <i1> [#uses=1]
102 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
108 UnifiedReturnBlock: ; preds = %entry
112 define void @testne2(i32 %x, i32 %n) nounwind {
114 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
115 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
116 %tmp4 = icmp ne i32 %tmp3, 0 ; <i1> [#uses=1]
117 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
123 UnifiedReturnBlock: ; preds = %entry
127 define void @testne2b(i32 %x, i32 %n) nounwind {
129 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
130 %tmp3 = and i32 1, %tmp29
131 %tmp4 = icmp ne i32 %tmp3, 0 ; <i1> [#uses=1]
132 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
138 UnifiedReturnBlock: ; preds = %entry
142 define void @atestne2(i32 %x, i32 %n) nounwind {
144 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
145 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
146 %tmp4 = icmp ne i32 %tmp3, 0 ; <i1> [#uses=1]
147 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
153 UnifiedReturnBlock: ; preds = %entry
157 define void @atestne2b(i32 %x, i32 %n) nounwind {
159 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
160 %tmp3 = and i32 1, %tmp29
161 %tmp4 = icmp ne i32 %tmp3, 0 ; <i1> [#uses=1]
162 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
168 UnifiedReturnBlock: ; preds = %entry
172 define void @testne3(i32 %x, i32 %n) nounwind {
174 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
175 %tmp3 = and i32 %tmp29, %x ; <i32> [#uses=1]
176 %tmp4 = icmp ne i32 %tmp3, 0 ; <i1> [#uses=1]
177 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
183 UnifiedReturnBlock: ; preds = %entry
187 define void @testne3b(i32 %x, i32 %n) nounwind {
189 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
190 %tmp3 = and i32 %x, %tmp29
191 %tmp4 = icmp ne i32 %tmp3, 0 ; <i1> [#uses=1]
192 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
198 UnifiedReturnBlock: ; preds = %entry
202 define void @query2(i32 %x, i32 %n) nounwind {
204 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
205 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
206 %tmp4 = icmp eq i32 %tmp3, 1 ; <i1> [#uses=1]
207 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
213 UnifiedReturnBlock: ; preds = %entry
217 define void @query2b(i32 %x, i32 %n) nounwind {
219 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
220 %tmp3 = and i32 1, %tmp29
221 %tmp4 = icmp eq i32 %tmp3, 1 ; <i1> [#uses=1]
222 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
228 UnifiedReturnBlock: ; preds = %entry
232 define void @aquery2(i32 %x, i32 %n) nounwind {
234 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
235 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
236 %tmp4 = icmp eq i32 %tmp3, 1 ; <i1> [#uses=1]
237 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
243 UnifiedReturnBlock: ; preds = %entry
247 define void @aquery2b(i32 %x, i32 %n) nounwind {
249 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
250 %tmp3 = and i32 1, %tmp29
251 %tmp4 = icmp eq i32 %tmp3, 1 ; <i1> [#uses=1]
252 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
258 UnifiedReturnBlock: ; preds = %entry
262 define void @query3(i32 %x, i32 %n) nounwind {
264 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
265 %tmp3 = and i32 %tmp29, %x ; <i32> [#uses=1]
266 %tmp4 = icmp eq i32 %tmp3, %tmp29 ; <i1> [#uses=1]
267 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
273 UnifiedReturnBlock: ; preds = %entry
277 define void @query3b(i32 %x, i32 %n) nounwind {
279 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
280 %tmp3 = and i32 %x, %tmp29
281 %tmp4 = icmp eq i32 %tmp3, %tmp29 ; <i1> [#uses=1]
282 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
288 UnifiedReturnBlock: ; preds = %entry
292 define void @query3x(i32 %x, i32 %n) nounwind {
294 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
295 %tmp3 = and i32 %tmp29, %x ; <i32> [#uses=1]
296 %tmp4 = icmp eq i32 %tmp29, %tmp3 ; <i1> [#uses=1]
297 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
303 UnifiedReturnBlock: ; preds = %entry
307 define void @query3bx(i32 %x, i32 %n) nounwind {
309 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
310 %tmp3 = and i32 %x, %tmp29
311 %tmp4 = icmp eq i32 %tmp29, %tmp3 ; <i1> [#uses=1]
312 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
318 UnifiedReturnBlock: ; preds = %entry
322 define void @queryne2(i32 %x, i32 %n) nounwind {
324 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
325 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
326 %tmp4 = icmp ne i32 %tmp3, 1 ; <i1> [#uses=1]
327 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
333 UnifiedReturnBlock: ; preds = %entry
337 define void @queryne2b(i32 %x, i32 %n) nounwind {
339 %tmp29 = lshr i32 %x, %n ; <i32> [#uses=1]
340 %tmp3 = and i32 1, %tmp29
341 %tmp4 = icmp ne i32 %tmp3, 1 ; <i1> [#uses=1]
342 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
348 UnifiedReturnBlock: ; preds = %entry
352 define void @aqueryne2(i32 %x, i32 %n) nounwind {
354 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
355 %tmp3 = and i32 %tmp29, 1 ; <i32> [#uses=1]
356 %tmp4 = icmp ne i32 %tmp3, 1 ; <i1> [#uses=1]
357 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
363 UnifiedReturnBlock: ; preds = %entry
367 define void @aqueryne2b(i32 %x, i32 %n) nounwind {
369 %tmp29 = ashr i32 %x, %n ; <i32> [#uses=1]
370 %tmp3 = and i32 1, %tmp29
371 %tmp4 = icmp ne i32 %tmp3, 1 ; <i1> [#uses=1]
372 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
378 UnifiedReturnBlock: ; preds = %entry
382 define void @queryne3(i32 %x, i32 %n) nounwind {
384 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
385 %tmp3 = and i32 %tmp29, %x ; <i32> [#uses=1]
386 %tmp4 = icmp ne i32 %tmp3, %tmp29 ; <i1> [#uses=1]
387 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
393 UnifiedReturnBlock: ; preds = %entry
397 define void @queryne3b(i32 %x, i32 %n) nounwind {
399 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
400 %tmp3 = and i32 %x, %tmp29
401 %tmp4 = icmp ne i32 %tmp3, %tmp29 ; <i1> [#uses=1]
402 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
408 UnifiedReturnBlock: ; preds = %entry
412 define void @queryne3x(i32 %x, i32 %n) nounwind {
414 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
415 %tmp3 = and i32 %tmp29, %x ; <i32> [#uses=1]
416 %tmp4 = icmp ne i32 %tmp29, %tmp3 ; <i1> [#uses=1]
417 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
423 UnifiedReturnBlock: ; preds = %entry
427 define void @queryne3bx(i32 %x, i32 %n) nounwind {
429 %tmp29 = shl i32 1, %n ; <i32> [#uses=1]
430 %tmp3 = and i32 %x, %tmp29
431 %tmp4 = icmp ne i32 %tmp29, %tmp3 ; <i1> [#uses=1]
432 br i1 %tmp4, label %bb, label %UnifiedReturnBlock
438 UnifiedReturnBlock: ; preds = %entry