1 ; Test ORs of a constant into a byte of memory.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
5 ; Check the lowest useful constant, expressed as a signed integer.
6 define void @f1(i8 *%ptr) {
10 %val = load i8, i8 *%ptr
11 %or = or i8 %val, -255
12 store i8 %or, i8 *%ptr
16 ; Check the highest useful constant, expressed as a signed integer.
17 define void @f2(i8 *%ptr) {
19 ; CHECK: oi 0(%r2), 254
21 %val = load i8, i8 *%ptr
23 store i8 %or, i8 *%ptr
27 ; Check the lowest useful constant, expressed as an unsigned integer.
28 define void @f3(i8 *%ptr) {
32 %val = load i8, i8 *%ptr
34 store i8 %or, i8 *%ptr
38 ; Check the highest useful constant, expressed as a unsigned integer.
39 define void @f4(i8 *%ptr) {
41 ; CHECK: oi 0(%r2), 254
43 %val = load i8, i8 *%ptr
45 store i8 %or, i8 *%ptr
49 ; Check the high end of the OI range.
50 define void @f5(i8 *%src) {
52 ; CHECK: oi 4095(%r2), 127
54 %ptr = getelementptr i8, i8 *%src, i64 4095
55 %val = load i8, i8 *%ptr
57 store i8 %or, i8 *%ptr
61 ; Check the next byte up, which should use OIY instead of OI.
62 define void @f6(i8 *%src) {
64 ; CHECK: oiy 4096(%r2), 127
66 %ptr = getelementptr i8, i8 *%src, i64 4096
67 %val = load i8, i8 *%ptr
69 store i8 %or, i8 *%ptr
73 ; Check the high end of the OIY range.
74 define void @f7(i8 *%src) {
76 ; CHECK: oiy 524287(%r2), 127
78 %ptr = getelementptr i8, i8 *%src, i64 524287
79 %val = load i8, i8 *%ptr
81 store i8 %or, i8 *%ptr
85 ; Check the next byte up, which needs separate address logic.
86 ; Other sequences besides this one would be OK.
87 define void @f8(i8 *%src) {
89 ; CHECK: agfi %r2, 524288
90 ; CHECK: oi 0(%r2), 127
92 %ptr = getelementptr i8, i8 *%src, i64 524288
93 %val = load i8, i8 *%ptr
95 store i8 %or, i8 *%ptr
99 ; Check the high end of the negative OIY range.
100 define void @f9(i8 *%src) {
102 ; CHECK: oiy -1(%r2), 127
104 %ptr = getelementptr i8, i8 *%src, i64 -1
105 %val = load i8, i8 *%ptr
106 %or = or i8 %val, 127
107 store i8 %or, i8 *%ptr
111 ; Check the low end of the OIY range.
112 define void @f10(i8 *%src) {
114 ; CHECK: oiy -524288(%r2), 127
116 %ptr = getelementptr i8, i8 *%src, i64 -524288
117 %val = load i8, i8 *%ptr
118 %or = or i8 %val, 127
119 store i8 %or, i8 *%ptr
123 ; Check the next byte down, which needs separate address logic.
124 ; Other sequences besides this one would be OK.
125 define void @f11(i8 *%src) {
127 ; CHECK: agfi %r2, -524289
128 ; CHECK: oi 0(%r2), 127
130 %ptr = getelementptr i8, i8 *%src, i64 -524289
131 %val = load i8, i8 *%ptr
132 %or = or i8 %val, 127
133 store i8 %or, i8 *%ptr
137 ; Check that OI does not allow an index
138 define void @f12(i64 %src, i64 %index) {
140 ; CHECK: agr %r2, %r3
141 ; CHECK: oi 4095(%r2), 127
143 %add1 = add i64 %src, %index
144 %add2 = add i64 %add1, 4095
145 %ptr = inttoptr i64 %add2 to i8 *
146 %val = load i8, i8 *%ptr
147 %or = or i8 %val, 127
148 store i8 %or, i8 *%ptr
152 ; Check that OIY does not allow an index
153 define void @f13(i64 %src, i64 %index) {
155 ; CHECK: agr %r2, %r3
156 ; CHECK: oiy 4096(%r2), 127
158 %add1 = add i64 %src, %index
159 %add2 = add i64 %add1, 4096
160 %ptr = inttoptr i64 %add2 to i8 *
161 %val = load i8, i8 *%ptr
162 %or = or i8 %val, 127
163 store i8 %or, i8 *%ptr