1 ; Test XORs 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(ptr %ptr) {
10 %val = load i8, ptr %ptr
11 %xor = xor i8 %val, -255
12 store i8 %xor, ptr %ptr
16 ; Check the highest useful constant, expressed as a signed integer.
17 define void @f2(ptr %ptr) {
19 ; CHECK: xi 0(%r2), 254
21 %val = load i8, ptr %ptr
22 %xor = xor i8 %val, -2
23 store i8 %xor, ptr %ptr
27 ; Check the lowest useful constant, expressed as an unsigned integer.
28 define void @f3(ptr %ptr) {
32 %val = load i8, ptr %ptr
34 store i8 %xor, ptr %ptr
38 ; Check the highest useful constant, expressed as a unsigned integer.
39 define void @f4(ptr %ptr) {
41 ; CHECK: xi 0(%r2), 254
43 %val = load i8, ptr %ptr
44 %xor = xor i8 %val, 254
45 store i8 %xor, ptr %ptr
49 ; Check the high end of the XI range.
50 define void @f5(ptr %src) {
52 ; CHECK: xi 4095(%r2), 127
54 %ptr = getelementptr i8, ptr %src, i64 4095
55 %val = load i8, ptr %ptr
56 %xor = xor i8 %val, 127
57 store i8 %xor, ptr %ptr
61 ; Check the next byte up, which should use XIY instead of XI.
62 define void @f6(ptr %src) {
64 ; CHECK: xiy 4096(%r2), 127
66 %ptr = getelementptr i8, ptr %src, i64 4096
67 %val = load i8, ptr %ptr
68 %xor = xor i8 %val, 127
69 store i8 %xor, ptr %ptr
73 ; Check the high end of the XIY range.
74 define void @f7(ptr %src) {
76 ; CHECK: xiy 524287(%r2), 127
78 %ptr = getelementptr i8, ptr %src, i64 524287
79 %val = load i8, ptr %ptr
80 %xor = xor i8 %val, 127
81 store i8 %xor, ptr %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(ptr %src) {
89 ; CHECK: agfi %r2, 524288
90 ; CHECK: xi 0(%r2), 127
92 %ptr = getelementptr i8, ptr %src, i64 524288
93 %val = load i8, ptr %ptr
94 %xor = xor i8 %val, 127
95 store i8 %xor, ptr %ptr
99 ; Check the high end of the negative XIY range.
100 define void @f9(ptr %src) {
102 ; CHECK: xiy -1(%r2), 127
104 %ptr = getelementptr i8, ptr %src, i64 -1
105 %val = load i8, ptr %ptr
106 %xor = xor i8 %val, 127
107 store i8 %xor, ptr %ptr
111 ; Check the low end of the XIY range.
112 define void @f10(ptr %src) {
114 ; CHECK: xiy -524288(%r2), 127
116 %ptr = getelementptr i8, ptr %src, i64 -524288
117 %val = load i8, ptr %ptr
118 %xor = xor i8 %val, 127
119 store i8 %xor, ptr %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(ptr %src) {
127 ; CHECK: agfi %r2, -524289
128 ; CHECK: xi 0(%r2), 127
130 %ptr = getelementptr i8, ptr %src, i64 -524289
131 %val = load i8, ptr %ptr
132 %xor = xor i8 %val, 127
133 store i8 %xor, ptr %ptr
137 ; Check that XI does not allow an index
138 define void @f12(i64 %src, i64 %index) {
140 ; CHECK: agr %r2, %r3
141 ; CHECK: xi 4095(%r2), 127
143 %add1 = add i64 %src, %index
144 %add2 = add i64 %add1, 4095
145 %ptr = inttoptr i64 %add2 to ptr
146 %val = load i8, ptr %ptr
147 %xor = xor i8 %val, 127
148 store i8 %xor, ptr %ptr
152 ; Check that XIY does not allow an index
153 define void @f13(i64 %src, i64 %index) {
155 ; CHECK: agr %r2, %r3
156 ; CHECK: xiy 4096(%r2), 127
158 %add1 = add i64 %src, %index
159 %add2 = add i64 %add1, 4096
160 %ptr = inttoptr i64 %add2 to ptr
161 %val = load i8, ptr %ptr
162 %xor = xor i8 %val, 127
163 store i8 %xor, ptr %ptr