1 ; Test loading of 64-bit constants.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 declare void @foo(i64, i64, i64, i64)
6 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1 immarg)
16 ; Check the high end of the LGHI range.
19 ; CHECK: lghi %r2, 32767
24 ; Check the next value up, which must use LLILL instead.
27 ; CHECK: llill %r2, 32768
32 ; Check the high end of the LLILL range.
35 ; CHECK: llill %r2, 65535
40 ; Check the first useful LLILH value, which is the next one up.
48 ; Check the first useful LGFI value, which is the next one up again.
51 ; CHECK: lgfi %r2, 65537
56 ; Check the high end of the LGFI range.
59 ; CHECK: lgfi %r2, 2147483647
64 ; Check the next value up, which should use LLILH instead.
67 ; CHECK: llilh %r2, 32768
72 ; Check the next value up again, which should use LLILF.
75 ; CHECK: llilf %r2, 2147483649
80 ; Check the high end of the LLILH range.
83 ; CHECK: llilh %r2, 65535
88 ; Check the next value up, which must use LLILF.
91 ; CHECK: llilf %r2, 4294901761
96 ; Check the high end of the LLILF range.
99 ; CHECK: llilf %r2, 4294967295
100 ; CHECK-NEXT: br %r14
104 ; Check the lowest useful LLIHL value, which is the next one up.
107 ; CHECK: llihl %r2, 1
108 ; CHECK-NEXT: br %r14
112 ; Check the next value up, which must use a combination of two instructions.
115 ; CHECK: llihl %r2, 1
116 ; CHECK-NEXT: oill %r2, 1
117 ; CHECK-NEXT: br %r14
121 ; Check the high end of the OILL range.
124 ; CHECK: llihl %r2, 1
125 ; CHECK-NEXT: oill %r2, 65535
126 ; CHECK-NEXT: br %r14
130 ; Check the next value up, which should use OILH instead.
133 ; CHECK: llihl %r2, 1
134 ; CHECK-NEXT: oilh %r2, 1
135 ; CHECK-NEXT: br %r14
139 ; Check the next value up again, which should use OILF.
142 ; CHECK: llihl %r2, 1
143 ; CHECK-NEXT: oilf %r2, 65537
144 ; CHECK-NEXT: br %r14
148 ; Check the high end of the OILH range.
151 ; CHECK: llihl %r2, 1
152 ; CHECK-NEXT: oilh %r2, 65535
153 ; CHECK-NEXT: br %r14
157 ; Check the high end of the OILF range.
160 ; CHECK: llihl %r2, 1
161 ; CHECK-NEXT: oilf %r2, 4294967295
162 ; CHECK-NEXT: br %r14
166 ; Check the high end of the LLIHL range.
169 ; CHECK: llihl %r2, 65535
170 ; CHECK-NEXT: br %r14
171 ret i64 281470681743360
174 ; Check the lowest useful LLIHH value, which is 1<<32 greater than the above.
177 ; CHECK: llihh %r2, 1
178 ; CHECK-NEXT: br %r14
179 ret i64 281474976710656
182 ; Check the lowest useful LLIHF value, which is 1<<32 greater again.
185 ; CHECK: llihf %r2, 65537
186 ; CHECK-NEXT: br %r14
187 ret i64 281479271677952
190 ; Check the highest end of the LLIHH range.
193 ; CHECK: llihh %r2, 65535
194 ; CHECK-NEXT: br %r14
195 ret i64 -281474976710656
198 ; Check the next value up, which must use OILL too.
201 ; CHECK: llihh %r2, 65535
202 ; CHECK-NEXT: oill %r2, 1
203 ; CHECK-NEXT: br %r14
204 ret i64 -281474976710655
207 ; Check the high end of the LLIHF range.
210 ; CHECK: llihf %r2, 4294967295
211 ; CHECK-NEXT: br %r14
218 ; CHECK: lghi %r2, -1
219 ; CHECK-NEXT: br %r14
223 ; Check the low end of the LGHI range.
226 ; CHECK: lghi %r2, -32768
227 ; CHECK-NEXT: br %r14
231 ; Check the next value down, which must use LGFI instead.
234 ; CHECK: lgfi %r2, -32769
235 ; CHECK-NEXT: br %r14
239 ; Check the low end of the LGFI range.
242 ; CHECK: lgfi %r2, -2147483648
243 ; CHECK-NEXT: br %r14
247 ; Check the next value down, which needs a two-instruction sequence.
250 ; CHECK: llihf %r2, 4294967295
251 ; CHECK-NEXT: oilf %r2, 2147483647
252 ; CHECK-NEXT: br %r14
256 ; Check that constant loads are rematerialized.
259 ; CHECK-DAG: lghi %r2, 42
260 ; CHECK-DAG: lgfi %r3, 65537
261 ; CHECK-DAG: llilf %r4, 2147483649
262 ; CHECK-DAG: llihf %r5, 65537
263 ; CHECK: brasl %r14, foo@PLT
264 ; CHECK-DAG: llill %r2, 32768
265 ; CHECK-DAG: llilh %r3, 1
266 ; CHECK-DAG: llihl %r4, 1
267 ; CHECK-DAG: llihh %r5, 1
268 ; CHECK: brasl %r14, foo@PLT
269 ; CHECK-DAG: lghi %r2, 42
270 ; CHECK-DAG: lgfi %r3, 65537
271 ; CHECK-DAG: llilf %r4, 2147483649
272 ; CHECK-DAG: llihf %r5, 65537
273 ; CHECK: brasl %r14, foo@PLT
274 ; CHECK-DAG: llill %r2, 32768
275 ; CHECK-DAG: llilh %r3, 1
276 ; CHECK-DAG: llihl %r4, 1
277 ; CHECK-DAG: llihh %r5, 1
278 ; CHECK: brasl %r14, foo@PLT
279 ; CHECK: lghi %r2, 42
281 call void @foo(i64 42, i64 65537, i64 2147483649, i64 281479271677952)
282 call void @foo(i64 32768, i64 65536, i64 4294967296, i64 281474976710656)
283 call void @foo(i64 42, i64 65537, i64 2147483649, i64 281479271677952)
284 call void @foo(i64 32768, i64 65536, i64 4294967296, i64 281474976710656)
288 ; Verify that we do not crash on OR with two constant inputs
289 ; (this was PR34859).
290 define i64 @f32(ptr %ptr) {
292 ; CHECK: llihf %r1, 918324340
293 ; CHECK: oilf %r1, 1806197964
294 ; CHECK: la %r0, 1(%r1)
295 store i64 -1, ptr %ptr, align 8
296 %1 = load i64, ptr %ptr, align 8
297 %2 = icmp ne i64 %1, 0
298 %3 = zext i1 %2 to i64
299 %4 = or i64 %3, 3944173009226982604
300 store i64 %4, ptr %ptr, align 8
301 ret i64 3944173009226982604
304 ; Check that huge constants can be loaded during isel pseudo expansion. This
305 ; is the iteration count loaded into a register after dividing by 256.
306 define void @f33(ptr %Src, ptr %Dst) {
310 call void @llvm.memcpy.p0.p0.i64(ptr %Src, ptr %Dst, i64 1099511628032, i1 false)
314 define void @f34(ptr %Src, ptr %Dst) {
318 call void @llvm.memcpy.p0.p0.i64(ptr %Src, ptr %Dst, i64 2199023255552, i1 false)
322 define void @f35(ptr %Src, ptr %Dst) {
324 ; CHECK: iihf %r0, 8388607
325 ; CHECK: iilf %r0, 4294967295
326 call void @llvm.memcpy.p0.p0.i64(ptr %Src, ptr %Dst, i64 9223372036854775800, i1 false)