blob: 0133963b36d042e2c75c9292c7facb0018840a38 [file] [log] [blame]
Michael Kuperstein868dc652015-08-06 08:45:34 +00001; RUN: llc < %s -mtriple=x86_64-linux-gnu -o - | FileCheck %s
2
3; This test checks that only a single jae gets generated in the final code
4; for lowering the CMOV pseudos that get created for this IR. The tricky part
5; of this test is that it tests the special PHI operand rewriting code in
6; X86TargetLowering::EmitLoweredSelect.
7;
8; CHECK-LABEL: foo1:
9; CHECK: jae
10; CHECK-NOT: jae
11define double @foo1(float %p1, double %p2, double %p3) nounwind {
12entry:
13 %c1 = fcmp oge float %p1, 0.000000e+00
14 %d0 = fadd double %p2, 1.25e0
15 %d1 = fadd double %p3, 1.25e0
16 %d2 = select i1 %c1, double %d0, double %d1
17 %d3 = select i1 %c1, double %d2, double %p2
18 %d4 = select i1 %c1, double %d3, double %p3
19 %d5 = fsub double %d2, %d3
20 %d6 = fadd double %d5, %d4
21 ret double %d6
22}
23
24; This test checks that only a single jae gets generated in the final code
25; for lowering the CMOV pseudos that get created for this IR. The tricky part
26; of this test is that it tests the special PHI operand rewriting code in
27; X86TargetLowering::EmitLoweredSelect.
28;
29; CHECK-LABEL: foo2:
30; CHECK: jae
31; CHECK-NOT: jae
32define double @foo2(float %p1, double %p2, double %p3) nounwind {
33entry:
34 %c1 = fcmp oge float %p1, 0.000000e+00
35 %d0 = fadd double %p2, 1.25e0
36 %d1 = fadd double %p3, 1.25e0
37 %d2 = select i1 %c1, double %d0, double %d1
38 %d3 = select i1 %c1, double %p2, double %d2
39 %d4 = select i1 %c1, double %p3, double %d3
40 %d5 = fsub double %d2, %d3
41 %d6 = fadd double %d5, %d4
42 ret double %d6
43}
44
45; This test checks that only a single js gets generated in the final code
46; for lowering the CMOV pseudos that get created for this IR. The tricky part
47; of this test is that it tests the special PHI operand rewriting code in
48; X86TargetLowering::EmitLoweredSelect. It also tests to make sure all
49; the operands of the resulting instructions are from the proper places.
50;
51; CHECK-LABEL: foo3:
52; CHECK: js
53; CHECK-NOT: js
54; CHECK-LABEL: # BB#1:
55; CHECK-DAG: movapd %xmm2, %xmm1
56; CHECK-DAG: movapd %xmm2, %xmm0
57; CHECK-LABEL:.LBB2_2:
58; CHECK: divsd %xmm1, %xmm0
59; CHECK: ret
60define double @foo3(i32 %p1, double %p2, double %p3,
61 double %p4, double %p5) nounwind {
62entry:
63 %c1 = icmp slt i32 %p1, 0
64 %d2 = select i1 %c1, double %p2, double %p3
65 %d3 = select i1 %c1, double %p3, double %p4
66 %d4 = select i1 %c1, double %d2, double %d3
67 %d5 = fdiv double %d4, %d3
68 ret double %d5
69}
70
71; This test checks that only a single js gets generated in the final code
72; for lowering the CMOV pseudos that get created for this IR. The tricky part
73; of this test is that it tests the special PHI operand rewriting code in
74; X86TargetLowering::EmitLoweredSelect. It also tests to make sure all
75; the operands of the resulting instructions are from the proper places
76; when the "opposite condition" handling code in the compiler is used.
77; This should be the same code as foo3 above, because we use the opposite
78; condition code in the second two selects, but we also swap the operands
79; of the selects to give the same actual computation.
80;
81; CHECK-LABEL: foo4:
82; CHECK: js
83; CHECK-NOT: js
84; CHECK-LABEL: # BB#1:
85; CHECK-DAG: movapd %xmm2, %xmm1
86; CHECK-DAG: movapd %xmm2, %xmm0
87; CHECK-LABEL:.LBB3_2:
88; CHECK: divsd %xmm1, %xmm0
89; CHECK: ret
90define double @foo4(i32 %p1, double %p2, double %p3,
91 double %p4, double %p5) nounwind {
92entry:
93 %c1 = icmp slt i32 %p1, 0
94 %d2 = select i1 %c1, double %p2, double %p3
95 %c2 = icmp sge i32 %p1, 0
96 %d3 = select i1 %c2, double %p4, double %p3
97 %d4 = select i1 %c2, double %d3, double %d2
98 %d5 = fdiv double %d4, %d3
99 ret double %d5
100}