1; Test 64-bit signed comparisons in which the second operand is a constant.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check comparisons with 0.
6define double @f1(double %a, double %b, i64 %i1) {
7; CHECK-LABEL: f1:
8; CHECK: cgijl %r2, 0
9; CHECK: ldr %f0, %f2
10; CHECK: br %r14
11  %cond = icmp slt i64 %i1, 0
12  %tmp = select i1 %cond, double %a, double %b
13  %res = fadd double %tmp, 1.0
14  ret double %res
15}
16
17; Check comparisons with 1.
18define double @f2(double %a, double %b, i64 %i1) {
19; CHECK-LABEL: f2:
20; CHECK: cgijle %r2, 0
21; CHECK: ldr %f0, %f2
22; CHECK: br %r14
23  %cond = icmp slt i64 %i1, 1
24  %tmp = select i1 %cond, double %a, double %b
25  %res = fadd double %tmp, 1.0
26  ret double %res
27}
28
29; Check the high end of the CGIJ range.
30define double @f3(double %a, double %b, i64 %i1) {
31; CHECK-LABEL: f3:
32; CHECK: cgijl %r2, 127
33; CHECK: ldr %f0, %f2
34; CHECK: br %r14
35  %cond = icmp slt i64 %i1, 127
36  %tmp = select i1 %cond, double %a, double %b
37  %res = fadd double %tmp, 1.0
38  ret double %res
39}
40
41; Check the next value up, which must use CGHI instead.
42define double @f4(double %a, double %b, i64 %i1) {
43; CHECK-LABEL: f4:
44; CHECK: cghi %r2, 128
45; CHECK-NEXT: jl
46; CHECK: ldr %f0, %f2
47; CHECK: br %r14
48  %cond = icmp slt i64 %i1, 128
49  %tmp = select i1 %cond, double %a, double %b
50  %res = fadd double %tmp, 1.0
51  ret double %res
52}
53
54; Check the high end of the CGHI range.
55define double @f5(double %a, double %b, i64 %i1) {
56; CHECK-LABEL: f5:
57; CHECK: cghi %r2, 32767
58; CHECK-NEXT: jl
59; CHECK: ldr %f0, %f2
60; CHECK: br %r14
61  %cond = icmp slt i64 %i1, 32767
62  %tmp = select i1 %cond, double %a, double %b
63  %res = fadd double %tmp, 1.0
64  ret double %res
65}
66
67; Check the next value up, which must use CGFI.
68define double @f6(double %a, double %b, i64 %i1) {
69; CHECK-LABEL: f6:
70; CHECK: cgfi %r2, 32768
71; CHECK-NEXT: jl
72; CHECK: ldr %f0, %f2
73; CHECK: br %r14
74  %cond = icmp slt i64 %i1, 32768
75  %tmp = select i1 %cond, double %a, double %b
76  %res = fadd double %tmp, 1.0
77  ret double %res
78}
79
80; Check the high end of the CGFI range.
81define double @f7(double %a, double %b, i64 %i1) {
82; CHECK-LABEL: f7:
83; CHECK: cgfi %r2, 2147483647
84; CHECK-NEXT: jl
85; CHECK: ldr %f0, %f2
86; CHECK: br %r14
87  %cond = icmp slt i64 %i1, 2147483647
88  %tmp = select i1 %cond, double %a, double %b
89  %res = fadd double %tmp, 1.0
90  ret double %res
91}
92
93; Check the next value up, which must use register comparison.
94define double @f8(double %a, double %b, i64 %i1) {
95; CHECK-LABEL: f8:
96; CHECK: cgrjl
97; CHECK: ldr %f0, %f2
98; CHECK: br %r14
99  %cond = icmp slt i64 %i1, 2147483648
100  %tmp = select i1 %cond, double %a, double %b
101  %res = fadd double %tmp, 1.0
102  ret double %res
103}
104
105; Check the high end of the negative CGIJ range.
106define double @f9(double %a, double %b, i64 %i1) {
107; CHECK-LABEL: f9:
108; CHECK: cgijl %r2, -1
109; CHECK: ldr %f0, %f2
110; CHECK: br %r14
111  %cond = icmp slt i64 %i1, -1
112  %tmp = select i1 %cond, double %a, double %b
113  %res = fadd double %tmp, 1.0
114  ret double %res
115}
116
117; Check the low end of the CGIJ range.
118define double @f10(double %a, double %b, i64 %i1) {
119; CHECK-LABEL: f10:
120; CHECK: cgijl %r2, -128
121; CHECK: ldr %f0, %f2
122; CHECK: br %r14
123  %cond = icmp slt i64 %i1, -128
124  %tmp = select i1 %cond, double %a, double %b
125  %res = fadd double %tmp, 1.0
126  ret double %res
127}
128
129; Check the next value down, which must use CGHI instead.
130define double @f11(double %a, double %b, i64 %i1) {
131; CHECK-LABEL: f11:
132; CHECK: cghi %r2, -129
133; CHECK-NEXT: jl
134; CHECK: ldr %f0, %f2
135; CHECK: br %r14
136  %cond = icmp slt i64 %i1, -129
137  %tmp = select i1 %cond, double %a, double %b
138  %res = fadd double %tmp, 1.0
139  ret double %res
140}
141
142; Check the low end of the CGHI range.
143define double @f12(double %a, double %b, i64 %i1) {
144; CHECK-LABEL: f12:
145; CHECK: cghi %r2, -32768
146; CHECK-NEXT: jl
147; CHECK: ldr %f0, %f2
148; CHECK: br %r14
149  %cond = icmp slt i64 %i1, -32768
150  %tmp = select i1 %cond, double %a, double %b
151  %res = fadd double %tmp, 1.0
152  ret double %res
153}
154
155; Check the next value down, which must use CGFI instead.
156define double @f13(double %a, double %b, i64 %i1) {
157; CHECK-LABEL: f13:
158; CHECK: cgfi %r2, -32769
159; CHECK-NEXT: jl
160; CHECK: ldr %f0, %f2
161; CHECK: br %r14
162  %cond = icmp slt i64 %i1, -32769
163  %tmp = select i1 %cond, double %a, double %b
164  %res = fadd double %tmp, 1.0
165  ret double %res
166}
167
168; Check the low end of the CGFI range.
169define double @f14(double %a, double %b, i64 %i1) {
170; CHECK-LABEL: f14:
171; CHECK: cgfi %r2, -2147483648
172; CHECK-NEXT: jl
173; CHECK: ldr %f0, %f2
174; CHECK: br %r14
175  %cond = icmp slt i64 %i1, -2147483648
176  %tmp = select i1 %cond, double %a, double %b
177  %res = fadd double %tmp, 1.0
178  ret double %res
179}
180
181; Check the next value down, which must use register comparison.
182define double @f15(double %a, double %b, i64 %i1) {
183; CHECK-LABEL: f15:
184; CHECK: cgrjl
185; CHECK: ldr %f0, %f2
186; CHECK: br %r14
187  %cond = icmp slt i64 %i1, -2147483649
188  %tmp = select i1 %cond, double %a, double %b
189  %res = fadd double %tmp, 1.0
190  ret double %res
191}
192