1; Test 64-bit inequality 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: cgijlh %r2, 0
9; CHECK: ldr %f0, %f2
10; CHECK: br %r14
11  %cond = icmp ne 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 the high end of the CGIJ range.
18define double @f2(double %a, double %b, i64 %i1) {
19; CHECK-LABEL: f2:
20; CHECK: cgijlh %r2, 127
21; CHECK: ldr %f0, %f2
22; CHECK: br %r14
23  %cond = icmp ne i64 %i1, 127
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 next value up, which must use CGHI instead.
30define double @f3(double %a, double %b, i64 %i1) {
31; CHECK-LABEL: f3:
32; CHECK: cghi %r2, 128
33; CHECK-NEXT: jlh
34; CHECK: ldr %f0, %f2
35; CHECK: br %r14
36  %cond = icmp ne i64 %i1, 128
37  %tmp = select i1 %cond, double %a, double %b
38  %res = fadd double %tmp, 1.0
39  ret double %res
40}
41
42; Check the high end of the CGHI range.
43define double @f4(double %a, double %b, i64 %i1) {
44; CHECK-LABEL: f4:
45; CHECK: cghi %r2, 32767
46; CHECK-NEXT: jlh
47; CHECK: ldr %f0, %f2
48; CHECK: br %r14
49  %cond = icmp ne i64 %i1, 32767
50  %tmp = select i1 %cond, double %a, double %b
51  %res = fadd double %tmp, 1.0
52  ret double %res
53}
54
55; Check the next value up, which must use CGFI.
56define double @f5(double %a, double %b, i64 %i1) {
57; CHECK-LABEL: f5:
58; CHECK: cgfi %r2, 32768
59; CHECK-NEXT: jlh
60; CHECK: ldr %f0, %f2
61; CHECK: br %r14
62  %cond = icmp ne i64 %i1, 32768
63  %tmp = select i1 %cond, double %a, double %b
64  %res = fadd double %tmp, 1.0
65  ret double %res
66}
67
68; Check the high end of the CGFI range.
69define double @f6(double %a, double %b, i64 %i1) {
70; CHECK-LABEL: f6:
71; CHECK: cgfi %r2, 2147483647
72; CHECK-NEXT: jlh
73; CHECK: ldr %f0, %f2
74; CHECK: br %r14
75  %cond = icmp ne i64 %i1, 2147483647
76  %tmp = select i1 %cond, double %a, double %b
77  %res = fadd double %tmp, 1.0
78  ret double %res
79}
80
81; Check the next value up, which should use CLGFI instead.
82define double @f7(double %a, double %b, i64 %i1) {
83; CHECK-LABEL: f7:
84; CHECK: clgfi %r2, 2147483648
85; CHECK-NEXT: jlh
86; CHECK: ldr %f0, %f2
87; CHECK: br %r14
88  %cond = icmp ne i64 %i1, 2147483648
89  %tmp = select i1 %cond, double %a, double %b
90  %res = fadd double %tmp, 1.0
91  ret double %res
92}
93
94; Check the high end of the CLGFI range.
95define double @f8(double %a, double %b, i64 %i1) {
96; CHECK-LABEL: f8:
97; CHECK: clgfi %r2, 4294967295
98; CHECK-NEXT: jlh
99; CHECK: ldr %f0, %f2
100; CHECK: br %r14
101  %cond = icmp ne i64 %i1, 4294967295
102  %tmp = select i1 %cond, double %a, double %b
103  %res = fadd double %tmp, 1.0
104  ret double %res
105}
106
107; Check the next value up, which must use a register comparison.
108define double @f9(double %a, double %b, i64 %i1) {
109; CHECK-LABEL: f9:
110; CHECK: cgrjlh %r2,
111; CHECK: ldr %f0, %f2
112; CHECK: br %r14
113  %cond = icmp ne i64 %i1, 4294967296
114  %tmp = select i1 %cond, double %a, double %b
115  %res = fadd double %tmp, 1.0
116  ret double %res
117}
118
119; Check the high end of the negative CGIJ range.
120define double @f10(double %a, double %b, i64 %i1) {
121; CHECK-LABEL: f10:
122; CHECK: cgijlh %r2, -1
123; CHECK: ldr %f0, %f2
124; CHECK: br %r14
125  %cond = icmp ne i64 %i1, -1
126  %tmp = select i1 %cond, double %a, double %b
127  %res = fadd double %tmp, 1.0
128  ret double %res
129}
130
131; Check the low end of the CGIJ range.
132define double @f11(double %a, double %b, i64 %i1) {
133; CHECK-LABEL: f11:
134; CHECK: cgijlh %r2, -128
135; CHECK: ldr %f0, %f2
136; CHECK: br %r14
137  %cond = icmp ne i64 %i1, -128
138  %tmp = select i1 %cond, double %a, double %b
139  %res = fadd double %tmp, 1.0
140  ret double %res
141}
142
143; Check the next value down, which must use CGHI instead.
144define double @f12(double %a, double %b, i64 %i1) {
145; CHECK-LABEL: f12:
146; CHECK: cghi %r2, -129
147; CHECK-NEXT: jlh
148; CHECK: ldr %f0, %f2
149; CHECK: br %r14
150  %cond = icmp ne i64 %i1, -129
151  %tmp = select i1 %cond, double %a, double %b
152  %res = fadd double %tmp, 1.0
153  ret double %res
154}
155
156; Check the low end of the CGHI range.
157define double @f13(double %a, double %b, i64 %i1) {
158; CHECK-LABEL: f13:
159; CHECK: cghi %r2, -32768
160; CHECK-NEXT: jlh
161; CHECK: ldr %f0, %f2
162; CHECK: br %r14
163  %cond = icmp ne i64 %i1, -32768
164  %tmp = select i1 %cond, double %a, double %b
165  %res = fadd double %tmp, 1.0
166  ret double %res
167}
168
169; Check the next value down, which must use CGFI instead.
170define double @f14(double %a, double %b, i64 %i1) {
171; CHECK-LABEL: f14:
172; CHECK: cgfi %r2, -32769
173; CHECK-NEXT: jlh
174; CHECK: ldr %f0, %f2
175; CHECK: br %r14
176  %cond = icmp ne i64 %i1, -32769
177  %tmp = select i1 %cond, double %a, double %b
178  %res = fadd double %tmp, 1.0
179  ret double %res
180}
181
182; Check the low end of the CGFI range.
183define double @f15(double %a, double %b, i64 %i1) {
184; CHECK-LABEL: f15:
185; CHECK: cgfi %r2, -2147483648
186; CHECK-NEXT: jlh
187; CHECK: ldr %f0, %f2
188; CHECK: br %r14
189  %cond = icmp ne i64 %i1, -2147483648
190  %tmp = select i1 %cond, double %a, double %b
191  %res = fadd double %tmp, 1.0
192  ret double %res
193}
194
195; Check the next value down, which must use register comparison.
196define double @f16(double %a, double %b, i64 %i1) {
197; CHECK-LABEL: f16:
198; CHECK: cgrjlh
199; CHECK: ldr %f0, %f2
200; CHECK: br %r14
201  %cond = icmp ne i64 %i1, -2147483649
202  %tmp = select i1 %cond, double %a, double %b
203  %res = fadd double %tmp, 1.0
204  ret double %res
205}
206