1 ; Test 32-bit addition in which the second operand is variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
9 define i32 @f1(i32 %a, i32 %b) {
17 ; Check the low end of the A range.
18 define i32 @f2(i32 %a, ptr %src) {
20 ; CHECK: a %r2, 0(%r3)
22 %b = load i32, ptr %src
27 ; Check the high end of the aligned A range.
28 define i32 @f3(i32 %a, ptr %src) {
30 ; CHECK: a %r2, 4092(%r3)
32 %ptr = getelementptr i32, ptr %src, i64 1023
33 %b = load i32, ptr %ptr
38 ; Check the next word up, which should use AY instead of A.
39 define i32 @f4(i32 %a, ptr %src) {
41 ; CHECK: ay %r2, 4096(%r3)
43 %ptr = getelementptr i32, ptr %src, i64 1024
44 %b = load i32, ptr %ptr
49 ; Check the high end of the aligned AY range.
50 define i32 @f5(i32 %a, ptr %src) {
52 ; CHECK: ay %r2, 524284(%r3)
54 %ptr = getelementptr i32, ptr %src, i64 131071
55 %b = load i32, ptr %ptr
60 ; Check the next word up, which needs separate address logic.
61 ; Other sequences besides this one would be OK.
62 define i32 @f6(i32 %a, ptr %src) {
64 ; CHECK: agfi %r3, 524288
65 ; CHECK: a %r2, 0(%r3)
67 %ptr = getelementptr i32, ptr %src, i64 131072
68 %b = load i32, ptr %ptr
73 ; Check the high end of the negative aligned AY range.
74 define i32 @f7(i32 %a, ptr %src) {
76 ; CHECK: ay %r2, -4(%r3)
78 %ptr = getelementptr i32, ptr %src, i64 -1
79 %b = load i32, ptr %ptr
84 ; Check the low end of the AY range.
85 define i32 @f8(i32 %a, ptr %src) {
87 ; CHECK: ay %r2, -524288(%r3)
89 %ptr = getelementptr i32, ptr %src, i64 -131072
90 %b = load i32, ptr %ptr
95 ; Check the next word down, which needs separate address logic.
96 ; Other sequences besides this one would be OK.
97 define i32 @f9(i32 %a, ptr %src) {
99 ; CHECK: agfi %r3, -524292
100 ; CHECK: a %r2, 0(%r3)
102 %ptr = getelementptr i32, ptr %src, i64 -131073
103 %b = load i32, ptr %ptr
104 %add = add i32 %a, %b
108 ; Check that A allows an index.
109 define i32 @f10(i32 %a, i64 %src, i64 %index) {
111 ; CHECK: a %r2, 4092({{%r4,%r3|%r3,%r4}})
113 %add1 = add i64 %src, %index
114 %add2 = add i64 %add1, 4092
115 %ptr = inttoptr i64 %add2 to ptr
116 %b = load i32, ptr %ptr
117 %add = add i32 %a, %b
121 ; Check that AY allows an index.
122 define i32 @f11(i32 %a, i64 %src, i64 %index) {
124 ; CHECK: ay %r2, 4096({{%r4,%r3|%r3,%r4}})
126 %add1 = add i64 %src, %index
127 %add2 = add i64 %add1, 4096
128 %ptr = inttoptr i64 %add2 to ptr
129 %b = load i32, ptr %ptr
130 %add = add i32 %a, %b
134 ; Check that additions of spilled values can use A rather than AR.
135 define i32 @f12(ptr %ptr0) {
137 ; CHECK: brasl %r14, foo@PLT
138 ; CHECK: a %r2, 16{{[04]}}(%r15)
140 %ptr1 = getelementptr i32, ptr %ptr0, i64 2
141 %ptr2 = getelementptr i32, ptr %ptr0, i64 4
142 %ptr3 = getelementptr i32, ptr %ptr0, i64 6
143 %ptr4 = getelementptr i32, ptr %ptr0, i64 8
144 %ptr5 = getelementptr i32, ptr %ptr0, i64 10
145 %ptr6 = getelementptr i32, ptr %ptr0, i64 12
146 %ptr7 = getelementptr i32, ptr %ptr0, i64 14
147 %ptr8 = getelementptr i32, ptr %ptr0, i64 16
148 %ptr9 = getelementptr i32, ptr %ptr0, i64 18
150 %val0 = load i32, ptr %ptr0
151 %val1 = load i32, ptr %ptr1
152 %val2 = load i32, ptr %ptr2
153 %val3 = load i32, ptr %ptr3
154 %val4 = load i32, ptr %ptr4
155 %val5 = load i32, ptr %ptr5
156 %val6 = load i32, ptr %ptr6
157 %val7 = load i32, ptr %ptr7
158 %val8 = load i32, ptr %ptr8
159 %val9 = load i32, ptr %ptr9
161 %ret = call i32 @foo()
163 %add0 = add i32 %ret, %val0
164 %add1 = add i32 %add0, %val1
165 %add2 = add i32 %add1, %val2
166 %add3 = add i32 %add2, %val3
167 %add4 = add i32 %add3, %val4
168 %add5 = add i32 %add4, %val5
169 %add6 = add i32 %add5, %val6
170 %add7 = add i32 %add6, %val7
171 %add8 = add i32 %add7, %val8
172 %add9 = add i32 %add8, %val9