Add explicit -march=x86 to these tests so that they don't
[oota-llvm.git] / test / CodeGen / X86 / bt.ll
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
4 ; PR3253
5
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.
9
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 &
17 ;      instead of with 0.
18 ;    - The comparison can be commuted (only cases where neither
19 ;      operand is constant are included).
20 ;    - The and can be commuted.
21
22 define void @test2(i32 %x, i32 %n) nounwind {
23 entry:
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
28
29 bb:             ; preds = %entry
30         call void @foo()
31         ret void
32
33 UnifiedReturnBlock:             ; preds = %entry
34         ret void
35 }
36
37 define void @test2b(i32 %x, i32 %n) nounwind {
38 entry:
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
43
44 bb:             ; preds = %entry
45         call void @foo()
46         ret void
47
48 UnifiedReturnBlock:             ; preds = %entry
49         ret void
50 }
51
52 define void @atest2(i32 %x, i32 %n) nounwind {
53 entry:
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
58
59 bb:             ; preds = %entry
60         call void @foo()
61         ret void
62
63 UnifiedReturnBlock:             ; preds = %entry
64         ret void
65 }
66
67 define void @atest2b(i32 %x, i32 %n) nounwind {
68 entry:
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
73
74 bb:             ; preds = %entry
75         call void @foo()
76         ret void
77
78 UnifiedReturnBlock:             ; preds = %entry
79         ret void
80 }
81
82 define void @test3(i32 %x, i32 %n) nounwind {
83 entry:
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
88
89 bb:             ; preds = %entry
90         call void @foo()
91         ret void
92
93 UnifiedReturnBlock:             ; preds = %entry
94         ret void
95 }
96
97 define void @test3b(i32 %x, i32 %n) nounwind {
98 entry:
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
103
104 bb:             ; preds = %entry
105         call void @foo()
106         ret void
107
108 UnifiedReturnBlock:             ; preds = %entry
109         ret void
110 }
111
112 define void @testne2(i32 %x, i32 %n) nounwind {
113 entry:
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
118
119 bb:             ; preds = %entry
120         call void @foo()
121         ret void
122
123 UnifiedReturnBlock:             ; preds = %entry
124         ret void
125 }
126
127 define void @testne2b(i32 %x, i32 %n) nounwind {
128 entry:
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
133
134 bb:             ; preds = %entry
135         call void @foo()
136         ret void
137
138 UnifiedReturnBlock:             ; preds = %entry
139         ret void
140 }
141
142 define void @atestne2(i32 %x, i32 %n) nounwind {
143 entry:
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
148
149 bb:             ; preds = %entry
150         call void @foo()
151         ret void
152
153 UnifiedReturnBlock:             ; preds = %entry
154         ret void
155 }
156
157 define void @atestne2b(i32 %x, i32 %n) nounwind {
158 entry:
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
163
164 bb:             ; preds = %entry
165         call void @foo()
166         ret void
167
168 UnifiedReturnBlock:             ; preds = %entry
169         ret void
170 }
171
172 define void @testne3(i32 %x, i32 %n) nounwind {
173 entry:
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
178
179 bb:             ; preds = %entry
180         call void @foo()
181         ret void
182
183 UnifiedReturnBlock:             ; preds = %entry
184         ret void
185 }
186
187 define void @testne3b(i32 %x, i32 %n) nounwind {
188 entry:
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
193
194 bb:             ; preds = %entry
195         call void @foo()
196         ret void
197
198 UnifiedReturnBlock:             ; preds = %entry
199         ret void
200 }
201
202 define void @query2(i32 %x, i32 %n) nounwind {
203 entry:
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
208
209 bb:             ; preds = %entry
210         call void @foo()
211         ret void
212
213 UnifiedReturnBlock:             ; preds = %entry
214         ret void
215 }
216
217 define void @query2b(i32 %x, i32 %n) nounwind {
218 entry:
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
223
224 bb:             ; preds = %entry
225         call void @foo()
226         ret void
227
228 UnifiedReturnBlock:             ; preds = %entry
229         ret void
230 }
231
232 define void @aquery2(i32 %x, i32 %n) nounwind {
233 entry:
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
238
239 bb:             ; preds = %entry
240         call void @foo()
241         ret void
242
243 UnifiedReturnBlock:             ; preds = %entry
244         ret void
245 }
246
247 define void @aquery2b(i32 %x, i32 %n) nounwind {
248 entry:
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
253
254 bb:             ; preds = %entry
255         call void @foo()
256         ret void
257
258 UnifiedReturnBlock:             ; preds = %entry
259         ret void
260 }
261
262 define void @query3(i32 %x, i32 %n) nounwind {
263 entry:
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
268
269 bb:             ; preds = %entry
270         call void @foo()
271         ret void
272
273 UnifiedReturnBlock:             ; preds = %entry
274         ret void
275 }
276
277 define void @query3b(i32 %x, i32 %n) nounwind {
278 entry:
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
283
284 bb:             ; preds = %entry
285         call void @foo()
286         ret void
287
288 UnifiedReturnBlock:             ; preds = %entry
289         ret void
290 }
291
292 define void @query3x(i32 %x, i32 %n) nounwind {
293 entry:
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
298
299 bb:             ; preds = %entry
300         call void @foo()
301         ret void
302
303 UnifiedReturnBlock:             ; preds = %entry
304         ret void
305 }
306
307 define void @query3bx(i32 %x, i32 %n) nounwind {
308 entry:
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
313
314 bb:             ; preds = %entry
315         call void @foo()
316         ret void
317
318 UnifiedReturnBlock:             ; preds = %entry
319         ret void
320 }
321
322 define void @queryne2(i32 %x, i32 %n) nounwind {
323 entry:
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
328
329 bb:             ; preds = %entry
330         call void @foo()
331         ret void
332
333 UnifiedReturnBlock:             ; preds = %entry
334         ret void
335 }
336
337 define void @queryne2b(i32 %x, i32 %n) nounwind {
338 entry:
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
343
344 bb:             ; preds = %entry
345         call void @foo()
346         ret void
347
348 UnifiedReturnBlock:             ; preds = %entry
349         ret void
350 }
351
352 define void @aqueryne2(i32 %x, i32 %n) nounwind {
353 entry:
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
358
359 bb:             ; preds = %entry
360         call void @foo()
361         ret void
362
363 UnifiedReturnBlock:             ; preds = %entry
364         ret void
365 }
366
367 define void @aqueryne2b(i32 %x, i32 %n) nounwind {
368 entry:
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
373
374 bb:             ; preds = %entry
375         call void @foo()
376         ret void
377
378 UnifiedReturnBlock:             ; preds = %entry
379         ret void
380 }
381
382 define void @queryne3(i32 %x, i32 %n) nounwind {
383 entry:
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
388
389 bb:             ; preds = %entry
390         call void @foo()
391         ret void
392
393 UnifiedReturnBlock:             ; preds = %entry
394         ret void
395 }
396
397 define void @queryne3b(i32 %x, i32 %n) nounwind {
398 entry:
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
403
404 bb:             ; preds = %entry
405         call void @foo()
406         ret void
407
408 UnifiedReturnBlock:             ; preds = %entry
409         ret void
410 }
411
412 define void @queryne3x(i32 %x, i32 %n) nounwind {
413 entry:
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
418
419 bb:             ; preds = %entry
420         call void @foo()
421         ret void
422
423 UnifiedReturnBlock:             ; preds = %entry
424         ret void
425 }
426
427 define void @queryne3bx(i32 %x, i32 %n) nounwind {
428 entry:
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
433
434 bb:             ; preds = %entry
435         call void @foo()
436         ret void
437
438 UnifiedReturnBlock:             ; preds = %entry
439         ret void
440 }
441
442 declare void @foo()