blob: ca91f9ea2c2b185150e4580524a7bce47ddf35a8 [file] [log] [blame]
Benjamin Kramer302178b2012-10-07 15:34:27 +00001; RUN: llc -march x86 -mcpu pentium4 < %s | FileCheck %s -check-prefix=SSE
2; RUN: llc -march x86 -mcpu pentium3 < %s | FileCheck %s -check-prefix=NOSSE2
3; RUN: llc -march x86 -mcpu pentium2 < %s | FileCheck %s -check-prefix=NOSSE1
4; RUN: llc -march x86 -mcpu pentium < %s | FileCheck %s -check-prefix=NOCMOV
5; PR14035
6
7define double @test1(i32 %a, i32 %b, double %x) nounwind {
8 %cmp = icmp ugt i32 %a, %b
9 %sel = select i1 %cmp, double 99.0, double %x
10 ret double %sel
11
12; SSE: test1:
13; SSE: movsd
14
15; NOSSE2: test1:
16; NOSSE2: fcmovnbe
17
18; NOSSE1: test1:
19; NOSSE1: fcmovnbe
20
21; NOCMOV: test1:
22; NOCMOV: fstp
23
24}
25
26define double @test2(i32 %a, i32 %b, double %x) nounwind {
27 %cmp = icmp uge i32 %a, %b
28 %sel = select i1 %cmp, double 99.0, double %x
29 ret double %sel
30
31; SSE: test2:
32; SSE: movsd
33
34; NOSSE2: test2:
35; NOSSE2: fcmovnb
36
37; NOSSE1: test2:
38; NOSSE1: fcmovnb
39
40; NOCMOV: test2:
41; NOCMOV: fstp
42}
43
44define double @test3(i32 %a, i32 %b, double %x) nounwind {
45 %cmp = icmp ult i32 %a, %b
46 %sel = select i1 %cmp, double 99.0, double %x
47 ret double %sel
48
49; SSE: test3:
50; SSE: movsd
51
52; NOSSE2: test3:
53; NOSSE2: fcmovb
54
55; NOSSE1: test3:
56; NOSSE1: fcmovb
57
58; NOCMOV: test3:
59; NOCMOV: fstp
60}
61
62define double @test4(i32 %a, i32 %b, double %x) nounwind {
63 %cmp = icmp ule i32 %a, %b
64 %sel = select i1 %cmp, double 99.0, double %x
65 ret double %sel
66
67; SSE: test4:
68; SSE: movsd
69
70; NOSSE2: test4:
71; NOSSE2: fcmovbe
72
73; NOSSE1: test4:
74; NOSSE1: fcmovbe
75
76; NOCMOV: test4:
77; NOCMOV: fstp
78}
79
80define double @test5(i32 %a, i32 %b, double %x) nounwind {
81 %cmp = icmp sgt i32 %a, %b
82 %sel = select i1 %cmp, double 99.0, double %x
83 ret double %sel
84
85; SSE: test5:
86; SSE: movsd
87
88; NOSSE2: test5:
89; NOSSE2: fstp
90
91; NOSSE1: test5:
92; NOSSE1: fstp
93
94; NOCMOV: test5:
95; NOCMOV: fstp
96}
97
98define double @test6(i32 %a, i32 %b, double %x) nounwind {
99 %cmp = icmp sge i32 %a, %b
100 %sel = select i1 %cmp, double 99.0, double %x
101 ret double %sel
102
103; SSE: test6:
104; SSE: movsd
105
106; NOSSE2: test6:
107; NOSSE2: fstp
108
109; NOSSE1: test6:
110; NOSSE1: fstp
111
112; NOCMOV: test6:
113; NOCMOV: fstp
114}
115
116define double @test7(i32 %a, i32 %b, double %x) nounwind {
117 %cmp = icmp slt i32 %a, %b
118 %sel = select i1 %cmp, double 99.0, double %x
119 ret double %sel
120
121; SSE: test7:
122; SSE: movsd
123
124; NOSSE2: test7:
125; NOSSE2: fstp
126
127; NOSSE1: test7:
128; NOSSE1: fstp
129
130; NOCMOV: test7:
131; NOCMOV: fstp
132}
133
134define double @test8(i32 %a, i32 %b, double %x) nounwind {
135 %cmp = icmp sle i32 %a, %b
136 %sel = select i1 %cmp, double 99.0, double %x
137 ret double %sel
138
139; SSE: test8:
140; SSE: movsd
141
142; NOSSE2: test8:
143; NOSSE2: fstp
144
145; NOSSE1: test8:
146; NOSSE1: fstp
147
148; NOCMOV: test8:
149; NOCMOV: fstp
150}
151
152define float @test9(i32 %a, i32 %b, float %x) nounwind {
153 %cmp = icmp ugt i32 %a, %b
154 %sel = select i1 %cmp, float 99.0, float %x
155 ret float %sel
156
157; SSE: test9:
158; SSE: movss
159
160; NOSSE2: test9:
161; NOSSE2: movss
162
163; NOSSE1: test9:
164; NOSSE1: fcmovnbe
165
166; NOCMOV: test9:
167; NOCMOV: fstp
168}
169
170define float @test10(i32 %a, i32 %b, float %x) nounwind {
171 %cmp = icmp uge i32 %a, %b
172 %sel = select i1 %cmp, float 99.0, float %x
173 ret float %sel
174
175; SSE: test10:
176; SSE: movss
177
178; NOSSE2: test10:
179; NOSSE2: movss
180
181; NOSSE1: test10:
182; NOSSE1: fcmovnb
183
184; NOCMOV: test10:
185; NOCMOV: fstp
186}
187
188define float @test11(i32 %a, i32 %b, float %x) nounwind {
189 %cmp = icmp ult i32 %a, %b
190 %sel = select i1 %cmp, float 99.0, float %x
191 ret float %sel
192
193; SSE: test11:
194; SSE: movss
195
196; NOSSE2: test11:
197; NOSSE2: movss
198
199; NOSSE1: test11:
200; NOSSE1: fcmovb
201
202; NOCMOV: test11:
203; NOCMOV: fstp
204}
205
206define float @test12(i32 %a, i32 %b, float %x) nounwind {
207 %cmp = icmp ule i32 %a, %b
208 %sel = select i1 %cmp, float 99.0, float %x
209 ret float %sel
210
211; SSE: test12:
212; SSE: movss
213
214; NOSSE2: test12:
215; NOSSE2: movss
216
217; NOSSE1: test12:
218; NOSSE1: fcmovbe
219
220; NOCMOV: test12:
221; NOCMOV: fstp
222}
223
224define float @test13(i32 %a, i32 %b, float %x) nounwind {
225 %cmp = icmp sgt i32 %a, %b
226 %sel = select i1 %cmp, float 99.0, float %x
227 ret float %sel
228
229; SSE: test13:
230; SSE: movss
231
232; NOSSE2: test13:
233; NOSSE2: movss
234
235; NOSSE1: test13:
236; NOSSE1: fstp
237
238; NOCMOV: test13:
239; NOCMOV: fstp
240}
241
242define float @test14(i32 %a, i32 %b, float %x) nounwind {
243 %cmp = icmp sge i32 %a, %b
244 %sel = select i1 %cmp, float 99.0, float %x
245 ret float %sel
246
247; SSE: test14:
248; SSE: movss
249
250; NOSSE2: test14:
251; NOSSE2: movss
252
253; NOSSE1: test14:
254; NOSSE1: fstp
255
256; NOCMOV: test14:
257; NOCMOV: fstp
258}
259
260define float @test15(i32 %a, i32 %b, float %x) nounwind {
261 %cmp = icmp slt i32 %a, %b
262 %sel = select i1 %cmp, float 99.0, float %x
263 ret float %sel
264
265; SSE: test15:
266; SSE: movss
267
268; NOSSE2: test15:
269; NOSSE2: movss
270
271; NOSSE1: test15:
272; NOSSE1: fstp
273
274; NOCMOV: test15:
275; NOCMOV: fstp
276}
277
278define float @test16(i32 %a, i32 %b, float %x) nounwind {
279 %cmp = icmp sle i32 %a, %b
280 %sel = select i1 %cmp, float 99.0, float %x
281 ret float %sel
282
283; SSE: test16:
284; SSE: movss
285
286; NOSSE2: test16:
287; NOSSE2: movss
288
289; NOSSE1: test16:
290; NOSSE1: fstp
291
292; NOCMOV: test16:
293; NOCMOV: fstp
294}
295
296define x86_fp80 @test17(i32 %a, i32 %b, x86_fp80 %x) nounwind {
297 %cmp = icmp ugt i32 %a, %b
298 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
299 ret x86_fp80 %sel
300
301; SSE: test17:
302; SSE: fcmovnbe
303
304; NOSSE2: test17:
305; NOSSE2: fcmovnbe
306
307; NOSSE1: test17:
308; NOSSE1: fcmovnbe
309
310; NOCMOV: test17:
311; NOCMOV: fstp
312}
313
314define x86_fp80 @test18(i32 %a, i32 %b, x86_fp80 %x) nounwind {
315 %cmp = icmp uge i32 %a, %b
316 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
317 ret x86_fp80 %sel
318
319; SSE: test18:
320; SSE: fcmovnb
321
322; NOSSE2: test18:
323; NOSSE2: fcmovnb
324
325; NOSSE1: test18:
326; NOSSE1: fcmovnb
327
328; NOCMOV: test18:
329; NOCMOV: fstp
330}
331
332define x86_fp80 @test19(i32 %a, i32 %b, x86_fp80 %x) nounwind {
333 %cmp = icmp ult i32 %a, %b
334 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
335 ret x86_fp80 %sel
336
337; SSE: test19:
338; SSE: fcmovb
339
340; NOSSE2: test19:
341; NOSSE2: fcmovb
342
343; NOSSE1: test19:
344; NOSSE1: fcmovb
345
346; NOCMOV: test19:
347; NOCMOV: fstp
348}
349
350define x86_fp80 @test20(i32 %a, i32 %b, x86_fp80 %x) nounwind {
351 %cmp = icmp ule i32 %a, %b
352 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
353 ret x86_fp80 %sel
354
355; SSE: test20:
356; SSE: fcmovbe
357
358; NOSSE2: test20:
359; NOSSE2: fcmovbe
360
361; NOSSE1: test20:
362; NOSSE1: fcmovbe
363
364; NOCMOV: test20:
365; NOCMOV: fstp
366}
367
368define x86_fp80 @test21(i32 %a, i32 %b, x86_fp80 %x) nounwind {
369 %cmp = icmp sgt i32 %a, %b
370 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
371 ret x86_fp80 %sel
372
373; We don't emit a branch for fp80, why?
374; SSE: test21:
375; SSE: testb
376; SSE: fcmovne
377
378; NOSSE2: test21:
379; NOSSE2: testb
380; NOSSE2: fcmovne
381
382; NOSSE1: test21:
383; NOSSE1: testb
384; NOSSE1: fcmovne
385
386; NOCMOV: test21:
387; NOCMOV: fstp
388}
389
390define x86_fp80 @test22(i32 %a, i32 %b, x86_fp80 %x) nounwind {
391 %cmp = icmp sge i32 %a, %b
392 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
393 ret x86_fp80 %sel
394
395; SSE: test22:
396; SSE: testb
397; SSE: fcmovne
398
399; NOSSE2: test22:
400; NOSSE2: testb
401; NOSSE2: fcmovne
402
403; NOSSE1: test22:
404; NOSSE1: testb
405; NOSSE1: fcmovne
406
407; NOCMOV: test22:
408; NOCMOV: fstp
409}
410
411define x86_fp80 @test23(i32 %a, i32 %b, x86_fp80 %x) nounwind {
412 %cmp = icmp slt i32 %a, %b
413 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
414 ret x86_fp80 %sel
415
416; SSE: test23:
417; SSE: testb
418; SSE: fcmovne
419
420; NOSSE2: test23:
421; NOSSE2: testb
422; NOSSE2: fcmovne
423
424; NOSSE1: test23:
425; NOSSE1: testb
426; NOSSE1: fcmovne
427
428; NOCMOV: test23:
429; NOCMOV: fstp
430}
431
432define x86_fp80 @test24(i32 %a, i32 %b, x86_fp80 %x) nounwind {
433 %cmp = icmp sle i32 %a, %b
434 %sel = select i1 %cmp, x86_fp80 0xK4005C600000000000000, x86_fp80 %x
435 ret x86_fp80 %sel
436
437; SSE: test24:
438; SSE: testb
439; SSE: fcmovne
440
441; NOSSE2: test24:
442; NOSSE2: testb
443; NOSSE2: fcmovne
444
445; NOSSE1: test24:
446; NOSSE1: testb
447; NOSSE1: fcmovne
448
449; NOCMOV: test24:
450; NOCMOV: fstp
451}