1 ; Test moves of integers to byte memory locations.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check the low end of the unsigned range.
6 define void @f1(i8 *%ptr) {
14 ; Check the high end of the signed range.
15 define void @f2(i8 *%ptr) {
17 ; CHECK: mvi 0(%r2), 127
19 store i8 127, i8 *%ptr
23 ; Check the next value up.
24 define void @f3(i8 *%ptr) {
26 ; CHECK: mvi 0(%r2), 128
28 store i8 -128, i8 *%ptr
32 ; Check the high end of the unsigned range.
33 define void @f4(i8 *%ptr) {
35 ; CHECK: mvi 0(%r2), 255
37 store i8 255, i8 *%ptr
42 define void @f5(i8 *%ptr) {
44 ; CHECK: mvi 0(%r2), 255
50 ; Check the low end of the signed range.
51 define void @f6(i8 *%ptr) {
53 ; CHECK: mvi 0(%r2), 128
55 store i8 -128, i8 *%ptr
59 ; Check the next value down.
60 define void @f7(i8 *%ptr) {
62 ; CHECK: mvi 0(%r2), 127
64 store i8 -129, i8 *%ptr
68 ; Check the high end of the MVI range.
69 define void @f8(i8 *%src) {
71 ; CHECK: mvi 4095(%r2), 42
73 %ptr = getelementptr i8, i8 *%src, i64 4095
78 ; Check the next byte up, which should use MVIY instead of MVI.
79 define void @f9(i8 *%src) {
81 ; CHECK: mviy 4096(%r2), 42
83 %ptr = getelementptr i8, i8 *%src, i64 4096
88 ; Check the high end of the MVIY range.
89 define void @f10(i8 *%src) {
91 ; CHECK: mviy 524287(%r2), 42
93 %ptr = getelementptr i8, i8 *%src, i64 524287
98 ; Check the next byte up, which needs separate address logic.
99 ; Other sequences besides this one would be OK.
100 define void @f11(i8 *%src) {
102 ; CHECK: agfi %r2, 524288
103 ; CHECK: mvi 0(%r2), 42
105 %ptr = getelementptr i8, i8 *%src, i64 524288
106 store i8 42, i8 *%ptr
110 ; Check the high end of the negative MVIY range.
111 define void @f12(i8 *%src) {
113 ; CHECK: mviy -1(%r2), 42
115 %ptr = getelementptr i8, i8 *%src, i64 -1
116 store i8 42, i8 *%ptr
120 ; Check the low end of the MVIY range.
121 define void @f13(i8 *%src) {
123 ; CHECK: mviy -524288(%r2), 42
125 %ptr = getelementptr i8, i8 *%src, i64 -524288
126 store i8 42, i8 *%ptr
130 ; Check the next byte down, which needs separate address logic.
131 ; Other sequences besides this one would be OK.
132 define void @f14(i8 *%src) {
134 ; CHECK: agfi %r2, -524289
135 ; CHECK: mvi 0(%r2), 42
137 %ptr = getelementptr i8, i8 *%src, i64 -524289
138 store i8 42, i8 *%ptr
142 ; Check that MVI does not allow an index. We prefer STC in that case.
143 define void @f15(i64 %src, i64 %index) {
145 ; CHECK: lhi [[TMP:%r[0-5]]], 42
146 ; CHECK: stc [[TMP]], 4095({{%r2,%r3|%r3,%r2}}
148 %add1 = add i64 %src, %index
149 %add2 = add i64 %add1, 4095
150 %ptr = inttoptr i64 %add2 to i8 *
151 store i8 42, i8 *%ptr
155 ; Check that MVIY does not allow an index. We prefer STCY in that case.
156 define void @f16(i64 %src, i64 %index) {
158 ; CHECK: lhi [[TMP:%r[0-5]]], 42
159 ; CHECK: stcy [[TMP]], 4096({{%r2,%r3|%r3,%r2}}
161 %add1 = add i64 %src, %index
162 %add2 = add i64 %add1, 4096
163 %ptr = inttoptr i64 %add2 to i8 *
164 store i8 42, i8 *%ptr