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