1 ; Test 8-bit GPR stores.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Test an i8 store, which should get converted into an i32 truncation.
6 define void @f1(i8 *%dst, i8 %val) {
8 ; CHECK: stc %r3, 0(%r2)
10 store i8 %val, i8 *%dst
14 ; Test an i32 truncating store.
15 define void @f2(i8 *%dst, i32 %val) {
17 ; CHECK: stc %r3, 0(%r2)
19 %trunc = trunc i32 %val to i8
20 store i8 %trunc, i8 *%dst
24 ; Test an i64 truncating store.
25 define void @f3(i8 *%dst, i64 %val) {
27 ; CHECK: stc %r3, 0(%r2)
29 %trunc = trunc i64 %val to i8
30 store i8 %trunc, i8 *%dst
34 ; Check the high end of the STC range.
35 define void @f4(i8 *%dst, i8 %val) {
37 ; CHECK: stc %r3, 4095(%r2)
39 %ptr = getelementptr i8, i8 *%dst, i64 4095
40 store i8 %val, i8 *%ptr
44 ; Check the next byte up, which should use STCY instead of STC.
45 define void @f5(i8 *%dst, i8 %val) {
47 ; CHECK: stcy %r3, 4096(%r2)
49 %ptr = getelementptr i8, i8 *%dst, i64 4096
50 store i8 %val, i8 *%ptr
54 ; Check the high end of the STCY range.
55 define void @f6(i8 *%dst, i8 %val) {
57 ; CHECK: stcy %r3, 524287(%r2)
59 %ptr = getelementptr i8, i8 *%dst, i64 524287
60 store i8 %val, i8 *%ptr
64 ; Check the next byte up, which needs separate address logic.
65 ; Other sequences besides this one would be OK.
66 define void @f7(i8 *%dst, i8 %val) {
68 ; CHECK: agfi %r2, 524288
69 ; CHECK: stc %r3, 0(%r2)
71 %ptr = getelementptr i8, i8 *%dst, i64 524288
72 store i8 %val, i8 *%ptr
76 ; Check the high end of the negative STCY range.
77 define void @f8(i8 *%dst, i8 %val) {
79 ; CHECK: stcy %r3, -1(%r2)
81 %ptr = getelementptr i8, i8 *%dst, i64 -1
82 store i8 %val, i8 *%ptr
86 ; Check the low end of the STCY range.
87 define void @f9(i8 *%dst, i8 %val) {
89 ; CHECK: stcy %r3, -524288(%r2)
91 %ptr = getelementptr i8, i8 *%dst, i64 -524288
92 store i8 %val, i8 *%ptr
96 ; Check the next byte down, which needs separate address logic.
97 ; Other sequences besides this one would be OK.
98 define void @f10(i8 *%dst, i8 %val) {
100 ; CHECK: agfi %r2, -524289
101 ; CHECK: stc %r3, 0(%r2)
103 %ptr = getelementptr i8, i8 *%dst, i64 -524289
104 store i8 %val, i8 *%ptr
108 ; Check that STC allows an index.
109 define void @f11(i64 %dst, i64 %index, i8 %val) {
111 ; CHECK: stc %r4, 4095(%r3,%r2)
113 %add1 = add i64 %dst, %index
114 %add2 = add i64 %add1, 4095
115 %ptr = inttoptr i64 %add2 to i8 *
116 store i8 %val, i8 *%ptr
120 ; Check that STCY allows an index.
121 define void @f12(i64 %dst, i64 %index, i8 %val) {
123 ; CHECK: stcy %r4, 4096(%r3,%r2)
125 %add1 = add i64 %dst, %index
126 %add2 = add i64 %add1, 4096
127 %ptr = inttoptr i64 %add2 to i8 *
128 store i8 %val, i8 *%ptr