1 ; Test 64-bit addition in which the second operand is variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s --check-prefixes=CHECK,Z10
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s --check-prefixes=CHECK,Z196
9 define i64 @f1(i64 %a, i64 %b) {
17 ; Check AG with no displacement.
18 define i64 @f2(i64 %a, ptr %src) {
20 ; CHECK: ag %r2, 0(%r3)
22 %b = load i64, ptr %src
27 ; Check the high end of the aligned AG range.
28 define i64 @f3(i64 %a, ptr %src) {
30 ; CHECK: ag %r2, 524280(%r3)
32 %ptr = getelementptr i64, ptr %src, i64 65535
33 %b = load i64, ptr %ptr
38 ; Check the next doubleword up, which needs separate address logic.
39 ; Other sequences besides this one would be OK.
40 define i64 @f4(i64 %a, ptr %src) {
42 ; CHECK: agfi %r3, 524288
43 ; CHECK: ag %r2, 0(%r3)
45 %ptr = getelementptr i64, ptr %src, i64 65536
46 %b = load i64, ptr %ptr
51 ; Check the high end of the negative aligned AG range.
52 define i64 @f5(i64 %a, ptr %src) {
54 ; CHECK: ag %r2, -8(%r3)
56 %ptr = getelementptr i64, ptr %src, i64 -1
57 %b = load i64, ptr %ptr
62 ; Check the low end of the AG range.
63 define i64 @f6(i64 %a, ptr %src) {
65 ; CHECK: ag %r2, -524288(%r3)
67 %ptr = getelementptr i64, ptr %src, i64 -65536
68 %b = load i64, ptr %ptr
73 ; Check the next doubleword down, which needs separate address logic.
74 ; Other sequences besides this one would be OK.
75 define i64 @f7(i64 %a, ptr %src) {
77 ; CHECK: agfi %r3, -524296
78 ; CHECK: ag %r2, 0(%r3)
80 %ptr = getelementptr i64, ptr %src, i64 -65537
81 %b = load i64, ptr %ptr
86 ; Check that AG allows an index.
87 define i64 @f8(i64 %a, i64 %src, i64 %index) {
89 ; CHECK: ag %r2, 524280({{%r4,%r3|%r3,%r4}})
91 %add1 = add i64 %src, %index
92 %add2 = add i64 %add1, 524280
93 %ptr = inttoptr i64 %add2 to ptr
94 %b = load i64, ptr %ptr
99 ; Check that additions of spilled values can use AG rather than AGR.
100 ; Note: Z196 is suboptimal with one unfolded reload.
101 define i64 @f9(ptr %ptr0) {
103 ; CHECK: brasl %r14, foo@PLT
104 ; Z10: ag %r2, 168(%r15)
105 ; Z196: ag %r0, 168(%r15)
107 %ptr1 = getelementptr i64, ptr %ptr0, i64 2
108 %ptr2 = getelementptr i64, ptr %ptr0, i64 4
109 %ptr3 = getelementptr i64, ptr %ptr0, i64 6
110 %ptr4 = getelementptr i64, ptr %ptr0, i64 8
111 %ptr5 = getelementptr i64, ptr %ptr0, i64 10
112 %ptr6 = getelementptr i64, ptr %ptr0, i64 12
113 %ptr7 = getelementptr i64, ptr %ptr0, i64 14
114 %ptr8 = getelementptr i64, ptr %ptr0, i64 16
115 %ptr9 = getelementptr i64, ptr %ptr0, i64 18
117 %val0 = load i64, ptr %ptr0
118 %val1 = load i64, ptr %ptr1
119 %val2 = load i64, ptr %ptr2
120 %val3 = load i64, ptr %ptr3
121 %val4 = load i64, ptr %ptr4
122 %val5 = load i64, ptr %ptr5
123 %val6 = load i64, ptr %ptr6
124 %val7 = load i64, ptr %ptr7
125 %val8 = load i64, ptr %ptr8
126 %val9 = load i64, ptr %ptr9
128 %ret = call i64 @foo()
130 %add0 = add i64 %ret, %val0
131 %add1 = add i64 %add0, %val1
132 %add2 = add i64 %add1, %val2
133 %add3 = add i64 %add2, %val3
134 %add4 = add i64 %add3, %val4
135 %add5 = add i64 %add4, %val5
136 %add6 = add i64 %add5, %val6
137 %add7 = add i64 %add6, %val7
138 %add8 = add i64 %add7, %val8
139 %add9 = add i64 %add8, %val9