1; Test loading of 32-bit constants.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5declare void @foo(i32, i32, i32, i32)
6
7; Check 0.
8define i32 @f1() {
9; CHECK-LABEL: f1:
10; CHECK: lhi %r2, 0
11; CHECK: br %r14
12  ret i32 0
13}
14
15; Check the high end of the LHI range.
16define i32 @f2() {
17; CHECK-LABEL: f2:
18; CHECK: lhi %r2, 32767
19; CHECK: br %r14
20  ret i32 32767
21}
22
23; Check the next value up, which must use LLILL instead.
24define i32 @f3() {
25; CHECK-LABEL: f3:
26; CHECK: llill %r2, 32768
27; CHECK: br %r14
28  ret i32 32768
29}
30
31; Check the high end of the LLILL range.
32define i32 @f4() {
33; CHECK-LABEL: f4:
34; CHECK: llill %r2, 65535
35; CHECK: br %r14
36  ret i32 65535
37}
38
39; Check the first useful LLILH value, which is the next one up.
40define i32 @f5() {
41; CHECK-LABEL: f5:
42; CHECK: llilh %r2, 1
43; CHECK: br %r14
44  ret i32 65536
45}
46
47; Check the first useful IILF value, which is the next one up again.
48define i32 @f6() {
49; CHECK-LABEL: f6:
50; CHECK: iilf %r2, 65537
51; CHECK: br %r14
52  ret i32 65537
53}
54
55; Check the high end of the LLILH range.
56define i32 @f7() {
57; CHECK-LABEL: f7:
58; CHECK: llilh %r2, 65535
59; CHECK: br %r14
60  ret i32 -65536
61}
62
63; Check the next value up, which must use IILF.
64define i32 @f8() {
65; CHECK-LABEL: f8:
66; CHECK: iilf %r2, 4294901761
67; CHECK: br %r14
68  ret i32 -65535
69}
70
71; Check the highest useful IILF value, 0xffff7fff
72define i32 @f9() {
73; CHECK-LABEL: f9:
74; CHECK: iilf %r2, 4294934527
75; CHECK: br %r14
76  ret i32 -32769
77}
78
79; Check the next value up, which should use LHI.
80define i32 @f10() {
81; CHECK-LABEL: f10:
82; CHECK: lhi %r2, -32768
83; CHECK: br %r14
84  ret i32 -32768
85}
86
87; Check -1.
88define i32 @f11() {
89; CHECK-LABEL: f11:
90; CHECK: lhi %r2, -1
91; CHECK: br %r14
92  ret i32 -1
93}
94
95; Check that constant loads are rematerialized.
96define i32 @f12() {
97; CHECK-LABEL: f12:
98; CHECK-DAG: lhi %r2, 42
99; CHECK-DAG: llill %r3, 32768
100; CHECK-DAG: llilh %r4, 1
101; CHECK-DAG: iilf %r5, 65537
102; CHECK: brasl %r14, foo@PLT
103; CHECK-DAG: lhi %r2, 42
104; CHECK-DAG: llill %r3, 32768
105; CHECK-DAG: llilh %r4, 1
106; CHECK-DAG: iilf %r5, 65537
107; CHECK: brasl %r14, foo@PLT
108; CHECK: lhi %r2, 42
109; CHECK: br %r14
110  call void @foo(i32 42, i32 32768, i32 65536, i32 65537)
111  call void @foo(i32 42, i32 32768, i32 65536, i32 65537)
112  ret i32 42
113}
114