1 ; Test 32-bit multiplication in which the second operand is variable.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
8 define i32 @f1(i32 %a, i32 %b) {
16 ; Check the low end of the MS range.
17 define i32 @f2(i32 %a, i32 *%src) {
19 ; CHECK: ms %r2, 0(%r3)
21 %b = load i32, i32 *%src
26 ; Check the high end of the aligned MS range.
27 define i32 @f3(i32 %a, i32 *%src) {
29 ; CHECK: ms %r2, 4092(%r3)
31 %ptr = getelementptr i32, i32 *%src, i64 1023
32 %b = load i32, i32 *%ptr
37 ; Check the next word up, which should use MSY instead of MS.
38 define i32 @f4(i32 %a, i32 *%src) {
40 ; CHECK: msy %r2, 4096(%r3)
42 %ptr = getelementptr i32, i32 *%src, i64 1024
43 %b = load i32, i32 *%ptr
48 ; Check the high end of the aligned MSY range.
49 define i32 @f5(i32 %a, i32 *%src) {
51 ; CHECK: msy %r2, 524284(%r3)
53 %ptr = getelementptr i32, i32 *%src, i64 131071
54 %b = load i32, i32 *%ptr
59 ; Check the next word up, which needs separate address logic.
60 ; Other sequences besides this one would be OK.
61 define i32 @f6(i32 %a, i32 *%src) {
63 ; CHECK: agfi %r3, 524288
64 ; CHECK: ms %r2, 0(%r3)
66 %ptr = getelementptr i32, i32 *%src, i64 131072
67 %b = load i32, i32 *%ptr
72 ; Check the high end of the negative aligned MSY range.
73 define i32 @f7(i32 %a, i32 *%src) {
75 ; CHECK: msy %r2, -4(%r3)
77 %ptr = getelementptr i32, i32 *%src, i64 -1
78 %b = load i32, i32 *%ptr
83 ; Check the low end of the MSY range.
84 define i32 @f8(i32 %a, i32 *%src) {
86 ; CHECK: msy %r2, -524288(%r3)
88 %ptr = getelementptr i32, i32 *%src, i64 -131072
89 %b = load i32, i32 *%ptr
94 ; Check the next word down, which needs separate address logic.
95 ; Other sequences besides this one would be OK.
96 define i32 @f9(i32 %a, i32 *%src) {
98 ; CHECK: agfi %r3, -524292
99 ; CHECK: ms %r2, 0(%r3)
101 %ptr = getelementptr i32, i32 *%src, i64 -131073
102 %b = load i32, i32 *%ptr
103 %mul = mul i32 %a, %b
107 ; Check that MS allows an index.
108 define i32 @f10(i32 %a, i64 %src, i64 %index) {
110 ; CHECK: ms %r2, 4092({{%r4,%r3|%r3,%r4}})
112 %add1 = add i64 %src, %index
113 %add2 = add i64 %add1, 4092
114 %ptr = inttoptr i64 %add2 to i32 *
115 %b = load i32, i32 *%ptr
116 %mul = mul i32 %a, %b
120 ; Check that MSY allows an index.
121 define i32 @f11(i32 %a, i64 %src, i64 %index) {
123 ; CHECK: msy %r2, 4096({{%r4,%r3|%r3,%r4}})
125 %add1 = add i64 %src, %index
126 %add2 = add i64 %add1, 4096
127 %ptr = inttoptr i64 %add2 to i32 *
128 %b = load i32, i32 *%ptr
129 %mul = mul i32 %a, %b
133 ; Check that multiplications of spilled values can use MS rather than MSR.
134 define i32 @f12(i32 *%ptr0) {
136 ; CHECK: brasl %r14, foo@PLT
137 ; CHECK: ms %r2, 16{{[04]}}(%r15)
139 %ptr1 = getelementptr i32, i32 *%ptr0, i64 2
140 %ptr2 = getelementptr i32, i32 *%ptr0, i64 4
141 %ptr3 = getelementptr i32, i32 *%ptr0, i64 6
142 %ptr4 = getelementptr i32, i32 *%ptr0, i64 8
143 %ptr5 = getelementptr i32, i32 *%ptr0, i64 10
144 %ptr6 = getelementptr i32, i32 *%ptr0, i64 12
145 %ptr7 = getelementptr i32, i32 *%ptr0, i64 14
146 %ptr8 = getelementptr i32, i32 *%ptr0, i64 16
147 %ptr9 = getelementptr i32, i32 *%ptr0, i64 18
149 %val0 = load i32, i32 *%ptr0
150 %val1 = load i32, i32 *%ptr1
151 %val2 = load i32, i32 *%ptr2
152 %val3 = load i32, i32 *%ptr3
153 %val4 = load i32, i32 *%ptr4
154 %val5 = load i32, i32 *%ptr5
155 %val6 = load i32, i32 *%ptr6
156 %val7 = load i32, i32 *%ptr7
157 %val8 = load i32, i32 *%ptr8
158 %val9 = load i32, i32 *%ptr9
160 %ret = call i32 @foo()
162 %mul0 = mul i32 %ret, %val0
163 %mul1 = mul i32 %mul0, %val1
164 %mul2 = mul i32 %mul1, %val2
165 %mul3 = mul i32 %mul2, %val3
166 %mul4 = mul i32 %mul3, %val4
167 %mul5 = mul i32 %mul4, %val5
168 %mul6 = mul i32 %mul5, %val6
169 %mul7 = mul i32 %mul6, %val7
170 %mul8 = mul i32 %mul7, %val8
171 %mul9 = mul i32 %mul8, %val9