1 ; RUN: llc < %s -march=x86-64 -asm-verbose=false | FileCheck %s
2 ; RUN: llc < %s -march=x86-64 -asm-verbose=false -enable-unsafe-fp-math -enable-no-nans-fp-math | FileCheck -check-prefix=UNSAFE %s
3 ; RUN: llc < %s -march=x86-64 -asm-verbose=false -enable-no-nans-fp-math | FileCheck -check-prefix=FINITE %s
5 ; Some of these patterns can be matched as SSE min or max. Some of
6 ; then can be matched provided that the operands are swapped.
7 ; Some of them can't be matched at all and require a comparison
8 ; and a conditional branch.
10 ; The naming convention is {,x_,y_}{o,u}{gt,lt,ge,le}{,_inverse}
11 ; x_ : use 0.0 instead of %y
12 ; y_ : use -0.0 instead of %y
13 ; _inverse : swap the arms of the select.
16 ; CHECK-NEXT: maxsd %xmm1, %xmm0
19 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
22 ; FINITE-NEXT: maxsd %xmm1, %xmm0
24 define double @ogt(double %x, double %y) nounwind {
25 %c = fcmp ogt double %x, %y
26 %d = select i1 %c, double %x, double %y
31 ; CHECK-NEXT: minsd %xmm1, %xmm0
34 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
37 ; FINITE-NEXT: minsd %xmm1, %xmm0
39 define double @olt(double %x, double %y) nounwind {
40 %c = fcmp olt double %x, %y
41 %d = select i1 %c, double %x, double %y
46 ; CHECK-NEXT: minsd %xmm0, %xmm1
47 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
49 ; UNSAFE: ogt_inverse:
50 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
51 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
53 ; FINITE: ogt_inverse:
54 ; FINITE-NEXT: minsd %xmm0, %xmm1
55 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
57 define double @ogt_inverse(double %x, double %y) nounwind {
58 %c = fcmp ogt double %x, %y
59 %d = select i1 %c, double %y, double %x
64 ; CHECK-NEXT: maxsd %xmm0, %xmm1
65 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
67 ; UNSAFE: olt_inverse:
68 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
69 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
71 ; FINITE: olt_inverse:
72 ; FINITE-NEXT: maxsd %xmm0, %xmm1
73 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
75 define double @olt_inverse(double %x, double %y) nounwind {
76 %c = fcmp olt double %x, %y
77 %d = select i1 %c, double %y, double %x
82 ; CHECK-NEXT: ucomisd %xmm1, %xmm0
84 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
87 ; FINITE-NEXT: maxsd %xmm1, %xmm0
89 define double @oge(double %x, double %y) nounwind {
90 %c = fcmp oge double %x, %y
91 %d = select i1 %c, double %x, double %y
96 ; CHECK-NEXT: ucomisd %xmm0, %xmm1
98 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
100 ; FINITE-NEXT: minsd %xmm1, %xmm0
101 define double @ole(double %x, double %y) nounwind {
102 %c = fcmp ole double %x, %y
103 %d = select i1 %c, double %x, double %y
107 ; CHECK: oge_inverse:
108 ; CHECK-NEXT: ucomisd %xmm1, %xmm0
109 ; UNSAFE: oge_inverse:
110 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
111 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
113 ; FINITE: oge_inverse:
114 ; FINITE-NEXT: minsd %xmm0, %xmm1
115 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
117 define double @oge_inverse(double %x, double %y) nounwind {
118 %c = fcmp oge double %x, %y
119 %d = select i1 %c, double %y, double %x
123 ; CHECK: ole_inverse:
124 ; CHECK-NEXT: ucomisd %xmm0, %xmm1
125 ; UNSAFE: ole_inverse:
126 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
127 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
129 ; FINITE: ole_inverse:
130 ; FINITE-NEXT: maxsd %xmm0, %xmm1
131 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
133 define double @ole_inverse(double %x, double %y) nounwind {
134 %c = fcmp ole double %x, %y
135 %d = select i1 %c, double %y, double %x
140 ; CHECK-NEXT: pxor %xmm1, %xmm1
141 ; CHECK-NEXT: maxsd %xmm1, %xmm0
144 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
145 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
148 ; FINITE-NEXT: pxor %xmm1, %xmm1
149 ; FINITE-NEXT: maxsd %xmm1, %xmm0
151 define double @x_ogt(double %x) nounwind {
152 %c = fcmp ogt double %x, 0.000000e+00
153 %d = select i1 %c, double %x, double 0.000000e+00
158 ; CHECK-NEXT: pxor %xmm1, %xmm1
159 ; CHECK-NEXT: minsd %xmm1, %xmm0
162 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
163 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
166 ; FINITE-NEXT: pxor %xmm1, %xmm1
167 ; FINITE-NEXT: minsd %xmm1, %xmm0
169 define double @x_olt(double %x) nounwind {
170 %c = fcmp olt double %x, 0.000000e+00
171 %d = select i1 %c, double %x, double 0.000000e+00
175 ; CHECK: x_ogt_inverse:
176 ; CHECK-NEXT: pxor %xmm1, %xmm1
177 ; CHECK-NEXT: minsd %xmm0, %xmm1
178 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
180 ; UNSAFE: x_ogt_inverse:
181 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
182 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
183 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
185 ; FINITE: x_ogt_inverse:
186 ; FINITE-NEXT: pxor %xmm1, %xmm1
187 ; FINITE-NEXT: minsd %xmm0, %xmm1
188 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
190 define double @x_ogt_inverse(double %x) nounwind {
191 %c = fcmp ogt double %x, 0.000000e+00
192 %d = select i1 %c, double 0.000000e+00, double %x
196 ; CHECK: x_olt_inverse:
197 ; CHECK-NEXT: pxor %xmm1, %xmm1
198 ; CHECK-NEXT: maxsd %xmm0, %xmm1
199 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
201 ; UNSAFE: x_olt_inverse:
202 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
203 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
204 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
206 ; FINITE: x_olt_inverse:
207 ; FINITE-NEXT: pxor %xmm1, %xmm1
208 ; FINITE-NEXT: maxsd %xmm0, %xmm1
209 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
211 define double @x_olt_inverse(double %x) nounwind {
212 %c = fcmp olt double %x, 0.000000e+00
213 %d = select i1 %c, double 0.000000e+00, double %x
218 ; CHECK: ucomisd %xmm1, %xmm0
220 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
221 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
224 ; FINITE-NEXT: pxor %xmm1, %xmm1
225 ; FINITE-NEXT: maxsd %xmm1, %xmm0
227 define double @x_oge(double %x) nounwind {
228 %c = fcmp oge double %x, 0.000000e+00
229 %d = select i1 %c, double %x, double 0.000000e+00
234 ; CHECK: ucomisd %xmm0, %xmm1
236 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
237 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
240 ; FINITE-NEXT: pxor %xmm1, %xmm1
241 ; FINITE-NEXT: minsd %xmm1, %xmm0
243 define double @x_ole(double %x) nounwind {
244 %c = fcmp ole double %x, 0.000000e+00
245 %d = select i1 %c, double %x, double 0.000000e+00
249 ; CHECK: x_oge_inverse:
250 ; CHECK: ucomisd %xmm1, %xmm0
251 ; UNSAFE: x_oge_inverse:
252 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
253 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
254 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
256 ; FINITE: x_oge_inverse:
257 ; FINITE-NEXT: pxor %xmm1, %xmm1
258 ; FINITE-NEXT: minsd %xmm0, %xmm1
259 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
261 define double @x_oge_inverse(double %x) nounwind {
262 %c = fcmp oge double %x, 0.000000e+00
263 %d = select i1 %c, double 0.000000e+00, double %x
267 ; CHECK: x_ole_inverse:
268 ; CHECK: ucomisd %xmm0, %xmm1
269 ; UNSAFE: x_ole_inverse:
270 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
271 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
272 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
274 ; FINITE: x_ole_inverse:
275 ; FINITE-NEXT: pxor %xmm1, %xmm1
276 ; FINITE-NEXT: maxsd %xmm0, %xmm1
277 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
279 define double @x_ole_inverse(double %x) nounwind {
280 %c = fcmp ole double %x, 0.000000e+00
281 %d = select i1 %c, double 0.000000e+00, double %x
286 ; CHECK: ucomisd %xmm0, %xmm1
288 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
291 ; FINITE-NEXT: maxsd %xmm1, %xmm0
293 define double @ugt(double %x, double %y) nounwind {
294 %c = fcmp ugt double %x, %y
295 %d = select i1 %c, double %x, double %y
300 ; CHECK: ucomisd %xmm1, %xmm0
302 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
305 ; FINITE-NEXT: minsd %xmm1, %xmm0
307 define double @ult(double %x, double %y) nounwind {
308 %c = fcmp ult double %x, %y
309 %d = select i1 %c, double %x, double %y
313 ; CHECK: ugt_inverse:
314 ; CHECK: ucomisd %xmm0, %xmm1
315 ; UNSAFE: ugt_inverse:
316 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
317 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
319 ; FINITE: ugt_inverse:
320 ; FINITE-NEXT: minsd %xmm0, %xmm1
321 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
323 define double @ugt_inverse(double %x, double %y) nounwind {
324 %c = fcmp ugt double %x, %y
325 %d = select i1 %c, double %y, double %x
329 ; CHECK: ult_inverse:
330 ; CHECK: ucomisd %xmm1, %xmm0
331 ; UNSAFE: ult_inverse:
332 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
333 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
335 ; FINITE: ult_inverse:
336 ; FINITE-NEXT: maxsd %xmm0, %xmm1
337 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
339 define double @ult_inverse(double %x, double %y) nounwind {
340 %c = fcmp ult double %x, %y
341 %d = select i1 %c, double %y, double %x
346 ; CHECK-NEXT: maxsd %xmm0, %xmm1
347 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
350 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
353 ; FINITE-NEXT: maxsd %xmm1, %xmm0
355 define double @uge(double %x, double %y) nounwind {
356 %c = fcmp uge double %x, %y
357 %d = select i1 %c, double %x, double %y
362 ; CHECK-NEXT: minsd %xmm0, %xmm1
363 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
366 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
369 ; FINITE-NEXT: minsd %xmm1, %xmm0
371 define double @ule(double %x, double %y) nounwind {
372 %c = fcmp ule double %x, %y
373 %d = select i1 %c, double %x, double %y
377 ; CHECK: uge_inverse:
378 ; CHECK-NEXT: minsd %xmm1, %xmm0
380 ; UNSAFE: uge_inverse:
381 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
382 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
384 ; FINITE: uge_inverse:
385 ; FINITE-NEXT: minsd %xmm0, %xmm1
386 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
388 define double @uge_inverse(double %x, double %y) nounwind {
389 %c = fcmp uge double %x, %y
390 %d = select i1 %c, double %y, double %x
394 ; CHECK: ule_inverse:
395 ; CHECK-NEXT: maxsd %xmm1, %xmm0
397 ; UNSAFE: ule_inverse:
398 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
399 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
401 ; FINITE: ule_inverse:
402 ; FINITE-NEXT: maxsd %xmm0, %xmm1
403 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
405 define double @ule_inverse(double %x, double %y) nounwind {
406 %c = fcmp ule double %x, %y
407 %d = select i1 %c, double %y, double %x
412 ; CHECK: ucomisd %xmm0, %xmm1
414 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
415 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
418 ; FINITE-NEXT: pxor %xmm1, %xmm1
419 ; FINITE-NEXT: maxsd %xmm1, %xmm0
421 define double @x_ugt(double %x) nounwind {
422 %c = fcmp ugt double %x, 0.000000e+00
423 %d = select i1 %c, double %x, double 0.000000e+00
428 ; CHECK: ucomisd %xmm1, %xmm0
430 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
431 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
434 ; FINITE-NEXT: pxor %xmm1, %xmm1
435 ; FINITE-NEXT: minsd %xmm1, %xmm0
437 define double @x_ult(double %x) nounwind {
438 %c = fcmp ult double %x, 0.000000e+00
439 %d = select i1 %c, double %x, double 0.000000e+00
443 ; CHECK: x_ugt_inverse:
444 ; CHECK: ucomisd %xmm0, %xmm1
445 ; UNSAFE: x_ugt_inverse:
446 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
447 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
448 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
450 ; FINITE: x_ugt_inverse:
451 ; FINITE-NEXT: pxor %xmm1, %xmm1
452 ; FINITE-NEXT: minsd %xmm0, %xmm1
453 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
455 define double @x_ugt_inverse(double %x) nounwind {
456 %c = fcmp ugt double %x, 0.000000e+00
457 %d = select i1 %c, double 0.000000e+00, double %x
461 ; CHECK: x_ult_inverse:
462 ; CHECK: ucomisd %xmm1, %xmm0
463 ; UNSAFE: x_ult_inverse:
464 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
465 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
466 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
468 ; FINITE: x_ult_inverse:
469 ; FINITE-NEXT: pxor %xmm1, %xmm1
470 ; FINITE-NEXT: maxsd %xmm0, %xmm1
471 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
473 define double @x_ult_inverse(double %x) nounwind {
474 %c = fcmp ult double %x, 0.000000e+00
475 %d = select i1 %c, double 0.000000e+00, double %x
480 ; CHECK-NEXT: pxor %xmm1, %xmm1
481 ; CHECK-NEXT: maxsd %xmm0, %xmm1
482 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
485 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
486 ; UNSAFE-NEXT: maxsd %xmm1, %xmm0
489 ; FINITE-NEXT: pxor %xmm1, %xmm1
490 ; FINITE-NEXT: maxsd %xmm1, %xmm0
492 define double @x_uge(double %x) nounwind {
493 %c = fcmp uge double %x, 0.000000e+00
494 %d = select i1 %c, double %x, double 0.000000e+00
499 ; CHECK-NEXT: pxor %xmm1, %xmm1
500 ; CHECK-NEXT: minsd %xmm0, %xmm1
501 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
504 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
505 ; UNSAFE-NEXT: minsd %xmm1, %xmm0
508 ; FINITE-NEXT: pxor %xmm1, %xmm1
509 ; FINITE-NEXT: minsd %xmm1, %xmm0
511 define double @x_ule(double %x) nounwind {
512 %c = fcmp ule double %x, 0.000000e+00
513 %d = select i1 %c, double %x, double 0.000000e+00
517 ; CHECK: x_uge_inverse:
518 ; CHECK-NEXT: pxor %xmm1, %xmm1
519 ; CHECK-NEXT: minsd %xmm1, %xmm0
521 ; UNSAFE: x_uge_inverse:
522 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
523 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
524 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
526 ; FINITE: x_uge_inverse:
527 ; FINITE-NEXT: pxor %xmm1, %xmm1
528 ; FINITE-NEXT: minsd %xmm0, %xmm1
529 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
531 define double @x_uge_inverse(double %x) nounwind {
532 %c = fcmp uge double %x, 0.000000e+00
533 %d = select i1 %c, double 0.000000e+00, double %x
537 ; CHECK: x_ule_inverse:
538 ; CHECK-NEXT: pxor %xmm1, %xmm1
539 ; CHECK-NEXT: maxsd %xmm1, %xmm0
541 ; UNSAFE: x_ule_inverse:
542 ; UNSAFE-NEXT: pxor %xmm1, %xmm1
543 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
544 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
546 ; FINITE: x_ule_inverse:
547 ; FINITE-NEXT: pxor %xmm1, %xmm1
548 ; FINITE-NEXT: maxsd %xmm0, %xmm1
549 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
551 define double @x_ule_inverse(double %x) nounwind {
552 %c = fcmp ule double %x, 0.000000e+00
553 %d = select i1 %c, double 0.000000e+00, double %x
558 ; CHECK-NEXT: maxsd {{[^,]*}}, %xmm0
561 ; UNSAFE-NEXT: maxsd {{[^,]*}}, %xmm0
564 ; FINITE-NEXT: maxsd {{[^,]*}}, %xmm0
566 define double @y_ogt(double %x) nounwind {
567 %c = fcmp ogt double %x, -0.000000e+00
568 %d = select i1 %c, double %x, double -0.000000e+00
573 ; CHECK-NEXT: minsd {{[^,]*}}, %xmm0
576 ; UNSAFE-NEXT: minsd {{[^,]*}}, %xmm0
579 ; FINITE-NEXT: minsd {{[^,]*}}, %xmm0
581 define double @y_olt(double %x) nounwind {
582 %c = fcmp olt double %x, -0.000000e+00
583 %d = select i1 %c, double %x, double -0.000000e+00
587 ; CHECK: y_ogt_inverse:
588 ; CHECK-NEXT: movsd {{[^,]*}}, %xmm1
589 ; CHECK-NEXT: minsd %xmm0, %xmm1
590 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
592 ; UNSAFE: y_ogt_inverse:
593 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
594 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
595 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
597 ; FINITE: y_ogt_inverse:
598 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
599 ; FINITE-NEXT: minsd %xmm0, %xmm1
600 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
602 define double @y_ogt_inverse(double %x) nounwind {
603 %c = fcmp ogt double %x, -0.000000e+00
604 %d = select i1 %c, double -0.000000e+00, double %x
608 ; CHECK: y_olt_inverse:
609 ; CHECK-NEXT: movsd {{[^,]*}}, %xmm1
610 ; CHECK-NEXT: maxsd %xmm0, %xmm1
611 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
613 ; UNSAFE: y_olt_inverse:
614 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
615 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
616 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
618 ; FINITE: y_olt_inverse:
619 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
620 ; FINITE-NEXT: maxsd %xmm0, %xmm1
621 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
623 define double @y_olt_inverse(double %x) nounwind {
624 %c = fcmp olt double %x, -0.000000e+00
625 %d = select i1 %c, double -0.000000e+00, double %x
630 ; CHECK: ucomisd %xmm1, %xmm0
632 ; UNSAFE-NEXT: maxsd {{[^,]*}}, %xmm0
635 ; FINITE-NEXT: maxsd {{[^,]*}}, %xmm0
637 define double @y_oge(double %x) nounwind {
638 %c = fcmp oge double %x, -0.000000e+00
639 %d = select i1 %c, double %x, double -0.000000e+00
644 ; CHECK: ucomisd %xmm0, %xmm1
646 ; UNSAFE-NEXT: minsd {{[^,]*}}, %xmm0
649 ; FINITE-NEXT: minsd {{[^,]*}}, %xmm0
651 define double @y_ole(double %x) nounwind {
652 %c = fcmp ole double %x, -0.000000e+00
653 %d = select i1 %c, double %x, double -0.000000e+00
657 ; CHECK: y_oge_inverse:
658 ; CHECK: ucomisd %xmm1, %xmm0
659 ; UNSAFE: y_oge_inverse:
660 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
661 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
662 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
664 ; FINITE: y_oge_inverse:
665 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
666 ; FINITE-NEXT: minsd %xmm0, %xmm1
667 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
669 define double @y_oge_inverse(double %x) nounwind {
670 %c = fcmp oge double %x, -0.000000e+00
671 %d = select i1 %c, double -0.000000e+00, double %x
675 ; CHECK: y_ole_inverse:
676 ; CHECK: ucomisd %xmm0, %xmm1
677 ; UNSAFE: y_ole_inverse:
678 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
679 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
680 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
682 ; FINITE: y_ole_inverse:
683 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
684 ; FINITE-NEXT: maxsd %xmm0, %xmm1
685 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
687 define double @y_ole_inverse(double %x) nounwind {
688 %c = fcmp ole double %x, -0.000000e+00
689 %d = select i1 %c, double -0.000000e+00, double %x
694 ; CHECK: ucomisd %xmm0, %xmm1
696 ; UNSAFE-NEXT: maxsd {{[^,]*}}, %xmm0
699 ; FINITE-NEXT: maxsd {{[^,]*}}, %xmm0
701 define double @y_ugt(double %x) nounwind {
702 %c = fcmp ugt double %x, -0.000000e+00
703 %d = select i1 %c, double %x, double -0.000000e+00
708 ; CHECK: ucomisd %xmm1, %xmm0
710 ; UNSAFE-NEXT: minsd {{[^,]*}}, %xmm0
713 ; FINITE-NEXT: minsd {{[^,]*}}, %xmm0
715 define double @y_ult(double %x) nounwind {
716 %c = fcmp ult double %x, -0.000000e+00
717 %d = select i1 %c, double %x, double -0.000000e+00
721 ; CHECK: y_ugt_inverse:
722 ; CHECK: ucomisd %xmm0, %xmm1
723 ; UNSAFE: y_ugt_inverse:
724 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
725 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
726 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
728 ; FINITE: y_ugt_inverse:
729 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
730 ; FINITE-NEXT: minsd %xmm0, %xmm1
731 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
733 define double @y_ugt_inverse(double %x) nounwind {
734 %c = fcmp ugt double %x, -0.000000e+00
735 %d = select i1 %c, double -0.000000e+00, double %x
739 ; CHECK: y_ult_inverse:
740 ; CHECK: ucomisd %xmm1, %xmm0
741 ; UNSAFE: y_ult_inverse:
742 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
743 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
744 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
746 ; FINITE: y_ult_inverse:
747 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
748 ; FINITE-NEXT: maxsd %xmm0, %xmm1
749 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
751 define double @y_ult_inverse(double %x) nounwind {
752 %c = fcmp ult double %x, -0.000000e+00
753 %d = select i1 %c, double -0.000000e+00, double %x
758 ; CHECK-NEXT: movsd {{[^,]*}}, %xmm1
759 ; CHECK-NEXT: maxsd %xmm0, %xmm1
760 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
763 ; UNSAFE-NEXT: maxsd {{[^,]*}}, %xmm0
766 ; FINITE-NEXT: maxsd {{[^,]*}}, %xmm0
768 define double @y_uge(double %x) nounwind {
769 %c = fcmp uge double %x, -0.000000e+00
770 %d = select i1 %c, double %x, double -0.000000e+00
775 ; CHECK-NEXT: movsd {{[^,]*}}, %xmm1
776 ; CHECK-NEXT: minsd %xmm0, %xmm1
777 ; CHECK-NEXT: movap{{[sd]}} %xmm1, %xmm0
780 ; UNSAFE-NEXT: minsd {{[^,]*}}, %xmm0
783 ; FINITE-NEXT: minsd {{[^,]*}}, %xmm0
785 define double @y_ule(double %x) nounwind {
786 %c = fcmp ule double %x, -0.000000e+00
787 %d = select i1 %c, double %x, double -0.000000e+00
791 ; CHECK: y_uge_inverse:
792 ; CHECK-NEXT: minsd {{[^,]*}}, %xmm0
794 ; UNSAFE: y_uge_inverse:
795 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
796 ; UNSAFE-NEXT: minsd %xmm0, %xmm1
797 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
799 ; FINITE: y_uge_inverse:
800 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
801 ; FINITE-NEXT: minsd %xmm0, %xmm1
802 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
804 define double @y_uge_inverse(double %x) nounwind {
805 %c = fcmp uge double %x, -0.000000e+00
806 %d = select i1 %c, double -0.000000e+00, double %x
810 ; CHECK: y_ule_inverse:
811 ; CHECK-NEXT: maxsd {{[^,]*}}, %xmm0
813 ; UNSAFE: y_ule_inverse:
814 ; UNSAFE-NEXT: movsd {{[^,]*}}, %xmm1
815 ; UNSAFE-NEXT: maxsd %xmm0, %xmm1
816 ; UNSAFE-NEXT: movap{{[sd]}} %xmm1, %xmm0
818 ; FINITE: y_ule_inverse:
819 ; FINITE-NEXT: movsd {{[^,]*}}, %xmm1
820 ; FINITE-NEXT: maxsd %xmm0, %xmm1
821 ; FINITE-NEXT: movap{{[sd]}} %xmm1, %xmm0
823 define double @y_ule_inverse(double %x) nounwind {
824 %c = fcmp ule double %x, -0.000000e+00
825 %d = select i1 %c, double -0.000000e+00, double %x
828 ; Test a few more misc. cases.
830 ; CHECK: clampTo3k_a:
832 ; UNSAFE: clampTo3k_a:
834 ; FINITE: clampTo3k_a:
836 define double @clampTo3k_a(double %x) nounwind readnone {
838 %0 = fcmp ogt double %x, 3.000000e+03 ; <i1> [#uses=1]
839 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
843 ; CHECK: clampTo3k_b:
845 ; UNSAFE: clampTo3k_b:
847 ; FINITE: clampTo3k_b:
849 define double @clampTo3k_b(double %x) nounwind readnone {
851 %0 = fcmp uge double %x, 3.000000e+03 ; <i1> [#uses=1]
852 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
856 ; CHECK: clampTo3k_c:
858 ; UNSAFE: clampTo3k_c:
860 ; FINITE: clampTo3k_c:
862 define double @clampTo3k_c(double %x) nounwind readnone {
864 %0 = fcmp olt double %x, 3.000000e+03 ; <i1> [#uses=1]
865 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
869 ; CHECK: clampTo3k_d:
871 ; UNSAFE: clampTo3k_d:
873 ; FINITE: clampTo3k_d:
875 define double @clampTo3k_d(double %x) nounwind readnone {
877 %0 = fcmp ule double %x, 3.000000e+03 ; <i1> [#uses=1]
878 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
882 ; CHECK: clampTo3k_e:
884 ; UNSAFE: clampTo3k_e:
886 ; FINITE: clampTo3k_e:
888 define double @clampTo3k_e(double %x) nounwind readnone {
890 %0 = fcmp olt double %x, 3.000000e+03 ; <i1> [#uses=1]
891 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
895 ; CHECK: clampTo3k_f:
897 ; UNSAFE: clampTo3k_f:
899 ; FINITE: clampTo3k_f:
901 define double @clampTo3k_f(double %x) nounwind readnone {
903 %0 = fcmp ule double %x, 3.000000e+03 ; <i1> [#uses=1]
904 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
908 ; CHECK: clampTo3k_g:
910 ; UNSAFE: clampTo3k_g:
912 ; FINITE: clampTo3k_g:
914 define double @clampTo3k_g(double %x) nounwind readnone {
916 %0 = fcmp ogt double %x, 3.000000e+03 ; <i1> [#uses=1]
917 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]
921 ; CHECK: clampTo3k_h:
923 ; UNSAFE: clampTo3k_h:
925 ; FINITE: clampTo3k_h:
927 define double @clampTo3k_h(double %x) nounwind readnone {
929 %0 = fcmp uge double %x, 3.000000e+03 ; <i1> [#uses=1]
930 %x_addr.0 = select i1 %0, double 3.000000e+03, double %x ; <double> [#uses=1]