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)
15 ; Check the high end of the LGHI range.
18 ; CHECK: lghi %r2, 32767
23 ; Check the next value up, which must use LLILL instead.
26 ; CHECK: llill %r2, 32768
31 ; Check the high end of the LLILL range.
34 ; CHECK: llill %r2, 65535
39 ; Check the first useful LLILH value, which is the next one up.
47 ; Check the first useful LGFI value, which is the next one up again.
50 ; CHECK: lgfi %r2, 65537
55 ; Check the high end of the LGFI range.
58 ; CHECK: lgfi %r2, 2147483647
63 ; Check the next value up, which should use LLILH instead.
66 ; CHECK: llilh %r2, 32768
71 ; Check the next value up again, which should use LLILF.
74 ; CHECK: llilf %r2, 2147483649
79 ; Check the high end of the LLILH range.
82 ; CHECK: llilh %r2, 65535
87 ; Check the next value up, which must use LLILF.
90 ; CHECK: llilf %r2, 4294901761
95 ; Check the high end of the LLILF range.
98 ; CHECK: llilf %r2, 4294967295
103 ; Check the lowest useful LLIHL value, which is the next one up.
106 ; CHECK: llihl %r2, 1
107 ; CHECK-NEXT: br %r14
111 ; Check the next value up, which must use a combination of two instructions.
114 ; CHECK: llihl %r2, 1
115 ; CHECK-NEXT: oill %r2, 1
116 ; CHECK-NEXT: br %r14
120 ; Check the high end of the OILL range.
123 ; CHECK: llihl %r2, 1
124 ; CHECK-NEXT: oill %r2, 65535
125 ; CHECK-NEXT: br %r14
129 ; Check the next value up, which should use OILH instead.
132 ; CHECK: llihl %r2, 1
133 ; CHECK-NEXT: oilh %r2, 1
134 ; CHECK-NEXT: br %r14
138 ; Check the next value up again, which should use OILF.
141 ; CHECK: llihl %r2, 1
142 ; CHECK-NEXT: oilf %r2, 65537
143 ; CHECK-NEXT: br %r14
147 ; Check the high end of the OILH range.
150 ; CHECK: llihl %r2, 1
151 ; CHECK-NEXT: oilh %r2, 65535
152 ; CHECK-NEXT: br %r14
156 ; Check the high end of the OILF range.
159 ; CHECK: llihl %r2, 1
160 ; CHECK-NEXT: oilf %r2, 4294967295
161 ; CHECK-NEXT: br %r14
165 ; Check the high end of the LLIHL range.
168 ; CHECK: llihl %r2, 65535
169 ; CHECK-NEXT: br %r14
170 ret i64 281470681743360
173 ; Check the lowest useful LLIHH value, which is 1<<32 greater than the above.
176 ; CHECK: llihh %r2, 1
177 ; CHECK-NEXT: br %r14
178 ret i64 281474976710656
181 ; Check the lowest useful LLIHF value, which is 1<<32 greater again.
184 ; CHECK: llihf %r2, 65537
185 ; CHECK-NEXT: br %r14
186 ret i64 281479271677952
189 ; Check the highest end of the LLIHH range.
192 ; CHECK: llihh %r2, 65535
193 ; CHECK-NEXT: br %r14
194 ret i64 -281474976710656
197 ; Check the next value up, which must use OILL too.
200 ; CHECK: llihh %r2, 65535
201 ; CHECK-NEXT: oill %r2, 1
202 ; CHECK-NEXT: br %r14
203 ret i64 -281474976710655
206 ; Check the high end of the LLIHF range.
209 ; CHECK: llihf %r2, 4294967295
210 ; CHECK-NEXT: br %r14
217 ; CHECK: lghi %r2, -1
218 ; CHECK-NEXT: br %r14
222 ; Check the low end of the LGHI range.
225 ; CHECK: lghi %r2, -32768
226 ; CHECK-NEXT: br %r14
230 ; Check the next value down, which must use LGFI instead.
233 ; CHECK: lgfi %r2, -32769
234 ; CHECK-NEXT: br %r14
238 ; Check the low end of the LGFI range.
241 ; CHECK: lgfi %r2, -2147483648
242 ; CHECK-NEXT: br %r14
246 ; Check the next value down, which needs a two-instruction sequence.
249 ; CHECK: llihf %r2, 4294967295
250 ; CHECK-NEXT: oilf %r2, 2147483647
251 ; CHECK-NEXT: br %r14
255 ; Check that constant loads are rematerialized.
258 ; CHECK-DAG: lghi %r2, 42
259 ; CHECK-DAG: lgfi %r3, 65537
260 ; CHECK-DAG: llilf %r4, 2147483649
261 ; CHECK-DAG: llihf %r5, 65537
262 ; CHECK: brasl %r14, foo@PLT
263 ; CHECK-DAG: llill %r2, 32768
264 ; CHECK-DAG: llilh %r3, 1
265 ; CHECK-DAG: llihl %r4, 1
266 ; CHECK-DAG: llihh %r5, 1
267 ; CHECK: brasl %r14, foo@PLT
268 ; CHECK-DAG: lghi %r2, 42
269 ; CHECK-DAG: lgfi %r3, 65537
270 ; CHECK-DAG: llilf %r4, 2147483649
271 ; CHECK-DAG: llihf %r5, 65537
272 ; CHECK: brasl %r14, foo@PLT
273 ; CHECK-DAG: llill %r2, 32768
274 ; CHECK-DAG: llilh %r3, 1
275 ; CHECK-DAG: llihl %r4, 1
276 ; CHECK-DAG: llihh %r5, 1
277 ; CHECK: brasl %r14, foo@PLT
278 ; CHECK: lghi %r2, 42
280 call void @foo(i64 42, i64 65537, i64 2147483649, i64 281479271677952)
281 call void @foo(i64 32768, i64 65536, i64 4294967296, i64 281474976710656)
282 call void @foo(i64 42, i64 65537, i64 2147483649, i64 281479271677952)
283 call void @foo(i64 32768, i64 65536, i64 4294967296, i64 281474976710656)
287 ; Verify that we do not crash on OR with two constant inputs
288 ; (this was PR34859).
289 define i64 @f32(i64 *%ptr) {
291 ; CHECK: llihf %r1, 918324340
292 ; CHECK: oilf %r1, 1806197964
293 ; CHECK: la %r0, 1(%r1)
294 store i64 -1, i64* %ptr, align 8
295 %1 = load i64, i64* %ptr, align 8
296 %2 = icmp ne i64 %1, 0
297 %3 = zext i1 %2 to i64
298 %4 = or i64 %3, 3944173009226982604
299 store i64 %4, i64* %ptr, align 8
300 ret i64 3944173009226982604