1; Test moves of integers to 4-byte memory locations.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; Check moves of zero.
6define void @f1(i32 *%a) {
7; CHECK-LABEL: f1:
8; CHECK: mvhi 0(%r2), 0
9; CHECK: br %r14
10  store i32 0, i32 *%a
11  ret void
12}
13
14; Check the high end of the signed 16-bit range.
15define void @f2(i32 *%a) {
16; CHECK-LABEL: f2:
17; CHECK: mvhi 0(%r2), 32767
18; CHECK: br %r14
19  store i32 32767, i32 *%a
20  ret void
21}
22
23; Check the next value up, which can't use MVHI.
24define void @f3(i32 *%a) {
25; CHECK-LABEL: f3:
26; CHECK-NOT: mvhi
27; CHECK: br %r14
28  store i32 32768, i32 *%a
29  ret void
30}
31
32; Check moves of -1.
33define void @f4(i32 *%a) {
34; CHECK-LABEL: f4:
35; CHECK: mvhi 0(%r2), -1
36; CHECK: br %r14
37  store i32 -1, i32 *%a
38  ret void
39}
40
41; Check the low end of the MVHI range.
42define void @f5(i32 *%a) {
43; CHECK-LABEL: f5:
44; CHECK: mvhi 0(%r2), -32768
45; CHECK: br %r14
46  store i32 -32768, i32 *%a
47  ret void
48}
49
50; Check the next value down, which can't use MVHI.
51define void @f6(i32 *%a) {
52; CHECK-LABEL: f6:
53; CHECK-NOT: mvhi
54; CHECK: br %r14
55  store i32 -32769, i32 *%a
56  ret void
57}
58
59; Check the high end of the MVHI range.
60define void @f7(i32 *%a) {
61; CHECK-LABEL: f7:
62; CHECK: mvhi 4092(%r2), 42
63; CHECK: br %r14
64  %ptr = getelementptr i32, i32 *%a, i64 1023
65  store i32 42, i32 *%ptr
66  ret void
67}
68
69; Check the next word up, which is out of range.  We prefer STY in that case.
70define void @f8(i32 *%a) {
71; CHECK-LABEL: f8:
72; CHECK: lhi [[TMP:%r[0-5]]], 42
73; CHECK: sty [[TMP]], 4096(%r2)
74; CHECK: br %r14
75  %ptr = getelementptr i32, i32 *%a, i64 1024
76  store i32 42, i32 *%ptr
77  ret void
78}
79
80; Check negative displacements, for which we again prefer STY.
81define void @f9(i32 *%a) {
82; CHECK-LABEL: f9:
83; CHECK: lhi [[TMP:%r[0-5]]], 42
84; CHECK: sty [[TMP]], -4(%r2)
85; CHECK: br %r14
86  %ptr = getelementptr i32, i32 *%a, i64 -1
87  store i32 42, i32 *%ptr
88  ret void
89}
90
91; Check that MVHI does not allow an index.
92define void @f10(i64 %src, i64 %index) {
93; CHECK-LABEL: f10:
94; CHECK: lhi [[TMP:%r[0-5]]], 42
95; CHECK: st [[TMP]], 0({{%r2,%r3|%r3,%r2}})
96; CHECK: br %r14
97  %add = add i64 %src, %index
98  %ptr = inttoptr i64 %add to i32 *
99  store i32 42, i32 *%ptr
100  ret void
101}
102