• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=x86 | grep btl | count 28
2; RUN: llc < %s -march=x86 -mcpu=pentium4 | grep btl | not grep esp
3; RUN: llc < %s -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
22define void @test2(i32 %x, i32 %n) nounwind {
23entry:
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
29bb:		; preds = %entry
30	call void @foo()
31	ret void
32
33UnifiedReturnBlock:		; preds = %entry
34	ret void
35}
36
37define void @test2b(i32 %x, i32 %n) nounwind {
38entry:
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
44bb:		; preds = %entry
45	call void @foo()
46	ret void
47
48UnifiedReturnBlock:		; preds = %entry
49	ret void
50}
51
52define void @atest2(i32 %x, i32 %n) nounwind {
53entry:
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
59bb:		; preds = %entry
60	call void @foo()
61	ret void
62
63UnifiedReturnBlock:		; preds = %entry
64	ret void
65}
66
67define void @atest2b(i32 %x, i32 %n) nounwind {
68entry:
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
74bb:		; preds = %entry
75	call void @foo()
76	ret void
77
78UnifiedReturnBlock:		; preds = %entry
79	ret void
80}
81
82define void @test3(i32 %x, i32 %n) nounwind {
83entry:
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
89bb:		; preds = %entry
90	call void @foo()
91	ret void
92
93UnifiedReturnBlock:		; preds = %entry
94	ret void
95}
96
97define void @test3b(i32 %x, i32 %n) nounwind {
98entry:
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
104bb:		; preds = %entry
105	call void @foo()
106	ret void
107
108UnifiedReturnBlock:		; preds = %entry
109	ret void
110}
111
112define void @testne2(i32 %x, i32 %n) nounwind {
113entry:
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
119bb:		; preds = %entry
120	call void @foo()
121	ret void
122
123UnifiedReturnBlock:		; preds = %entry
124	ret void
125}
126
127define void @testne2b(i32 %x, i32 %n) nounwind {
128entry:
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
134bb:		; preds = %entry
135	call void @foo()
136	ret void
137
138UnifiedReturnBlock:		; preds = %entry
139	ret void
140}
141
142define void @atestne2(i32 %x, i32 %n) nounwind {
143entry:
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
149bb:		; preds = %entry
150	call void @foo()
151	ret void
152
153UnifiedReturnBlock:		; preds = %entry
154	ret void
155}
156
157define void @atestne2b(i32 %x, i32 %n) nounwind {
158entry:
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
164bb:		; preds = %entry
165	call void @foo()
166	ret void
167
168UnifiedReturnBlock:		; preds = %entry
169	ret void
170}
171
172define void @testne3(i32 %x, i32 %n) nounwind {
173entry:
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
179bb:		; preds = %entry
180	call void @foo()
181	ret void
182
183UnifiedReturnBlock:		; preds = %entry
184	ret void
185}
186
187define void @testne3b(i32 %x, i32 %n) nounwind {
188entry:
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
194bb:		; preds = %entry
195	call void @foo()
196	ret void
197
198UnifiedReturnBlock:		; preds = %entry
199	ret void
200}
201
202define void @query2(i32 %x, i32 %n) nounwind {
203entry:
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
209bb:		; preds = %entry
210	call void @foo()
211	ret void
212
213UnifiedReturnBlock:		; preds = %entry
214	ret void
215}
216
217define void @query2b(i32 %x, i32 %n) nounwind {
218entry:
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
224bb:		; preds = %entry
225	call void @foo()
226	ret void
227
228UnifiedReturnBlock:		; preds = %entry
229	ret void
230}
231
232define void @aquery2(i32 %x, i32 %n) nounwind {
233entry:
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
239bb:		; preds = %entry
240	call void @foo()
241	ret void
242
243UnifiedReturnBlock:		; preds = %entry
244	ret void
245}
246
247define void @aquery2b(i32 %x, i32 %n) nounwind {
248entry:
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
254bb:		; preds = %entry
255	call void @foo()
256	ret void
257
258UnifiedReturnBlock:		; preds = %entry
259	ret void
260}
261
262define void @query3(i32 %x, i32 %n) nounwind {
263entry:
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
269bb:		; preds = %entry
270	call void @foo()
271	ret void
272
273UnifiedReturnBlock:		; preds = %entry
274	ret void
275}
276
277define void @query3b(i32 %x, i32 %n) nounwind {
278entry:
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
284bb:		; preds = %entry
285	call void @foo()
286	ret void
287
288UnifiedReturnBlock:		; preds = %entry
289	ret void
290}
291
292define void @query3x(i32 %x, i32 %n) nounwind {
293entry:
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
299bb:		; preds = %entry
300	call void @foo()
301	ret void
302
303UnifiedReturnBlock:		; preds = %entry
304	ret void
305}
306
307define void @query3bx(i32 %x, i32 %n) nounwind {
308entry:
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
314bb:		; preds = %entry
315	call void @foo()
316	ret void
317
318UnifiedReturnBlock:		; preds = %entry
319	ret void
320}
321
322define void @queryne2(i32 %x, i32 %n) nounwind {
323entry:
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
329bb:		; preds = %entry
330	call void @foo()
331	ret void
332
333UnifiedReturnBlock:		; preds = %entry
334	ret void
335}
336
337define void @queryne2b(i32 %x, i32 %n) nounwind {
338entry:
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
344bb:		; preds = %entry
345	call void @foo()
346	ret void
347
348UnifiedReturnBlock:		; preds = %entry
349	ret void
350}
351
352define void @aqueryne2(i32 %x, i32 %n) nounwind {
353entry:
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
359bb:		; preds = %entry
360	call void @foo()
361	ret void
362
363UnifiedReturnBlock:		; preds = %entry
364	ret void
365}
366
367define void @aqueryne2b(i32 %x, i32 %n) nounwind {
368entry:
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
374bb:		; preds = %entry
375	call void @foo()
376	ret void
377
378UnifiedReturnBlock:		; preds = %entry
379	ret void
380}
381
382define void @queryne3(i32 %x, i32 %n) nounwind {
383entry:
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
389bb:		; preds = %entry
390	call void @foo()
391	ret void
392
393UnifiedReturnBlock:		; preds = %entry
394	ret void
395}
396
397define void @queryne3b(i32 %x, i32 %n) nounwind {
398entry:
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
404bb:		; preds = %entry
405	call void @foo()
406	ret void
407
408UnifiedReturnBlock:		; preds = %entry
409	ret void
410}
411
412define void @queryne3x(i32 %x, i32 %n) nounwind {
413entry:
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
419bb:		; preds = %entry
420	call void @foo()
421	ret void
422
423UnifiedReturnBlock:		; preds = %entry
424	ret void
425}
426
427define void @queryne3bx(i32 %x, i32 %n) nounwind {
428entry:
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
434bb:		; preds = %entry
435	call void @foo()
436	ret void
437
438UnifiedReturnBlock:		; preds = %entry
439	ret void
440}
441
442declare void @foo()
443