1 ; Test strict multiplication of two f64s, producing an f128 result.
2 ; FIXME: we do not have a strict version of fpext yet
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 declare fp128 @llvm.experimental.constrained.fmul.f128(fp128, fp128, metadata, metadata)
10 ; Check register multiplication. "mxdbr %f0, %f2" is not valid from LLVM's
11 ; point of view, because %f2 is the low register of the FP128 %f0. Pass the
12 ; multiplier in %f4 instead.
13 define void @f1(double %f1, double %dummy, double %f2, fp128 *%dst) {
15 ; CHECK: mxdbr %f0, %f4
16 ; CHECK: std %f0, 0(%r2)
17 ; CHECK: std %f2, 8(%r2)
19 %f1x = fpext double %f1 to fp128
20 %f2x = fpext double %f2 to fp128
21 %res = call fp128 @llvm.experimental.constrained.fmul.f128(
22 fp128 %f1x, fp128 %f2x,
23 metadata !"round.dynamic",
24 metadata !"fpexcept.strict")
25 store fp128 %res, fp128 *%dst
29 ; Check the low end of the MXDB range.
30 define void @f2(double %f1, double *%ptr, fp128 *%dst) {
32 ; CHECK: mxdb %f0, 0(%r2)
33 ; CHECK: std %f0, 0(%r3)
34 ; CHECK: std %f2, 8(%r3)
36 %f2 = load double, double *%ptr
37 %f1x = fpext double %f1 to fp128
38 %f2x = fpext double %f2 to fp128
39 %res = call fp128 @llvm.experimental.constrained.fmul.f128(
40 fp128 %f1x, fp128 %f2x,
41 metadata !"round.dynamic",
42 metadata !"fpexcept.strict")
43 store fp128 %res, fp128 *%dst
47 ; Check the high end of the aligned MXDB range.
48 define void @f3(double %f1, double *%base, fp128 *%dst) {
50 ; CHECK: mxdb %f0, 4088(%r2)
51 ; CHECK: std %f0, 0(%r3)
52 ; CHECK: std %f2, 8(%r3)
54 %ptr = getelementptr double, double *%base, i64 511
55 %f2 = load double, double *%ptr
56 %f1x = fpext double %f1 to fp128
57 %f2x = fpext double %f2 to fp128
58 %res = call fp128 @llvm.experimental.constrained.fmul.f128(
59 fp128 %f1x, fp128 %f2x,
60 metadata !"round.dynamic",
61 metadata !"fpexcept.strict")
62 store fp128 %res, fp128 *%dst
66 ; Check the next doubleword up, which needs separate address logic.
67 ; Other sequences besides this one would be OK.
68 define void @f4(double %f1, double *%base, fp128 *%dst) {
70 ; CHECK: aghi %r2, 4096
71 ; CHECK: mxdb %f0, 0(%r2)
72 ; CHECK: std %f0, 0(%r3)
73 ; CHECK: std %f2, 8(%r3)
75 %ptr = getelementptr double, double *%base, i64 512
76 %f2 = load double, double *%ptr
77 %f1x = fpext double %f1 to fp128
78 %f2x = fpext double %f2 to fp128
79 %res = call fp128 @llvm.experimental.constrained.fmul.f128(
80 fp128 %f1x, fp128 %f2x,
81 metadata !"round.dynamic",
82 metadata !"fpexcept.strict")
83 store fp128 %res, fp128 *%dst
87 ; Check negative displacements, which also need separate address logic.
88 define void @f5(double %f1, double *%base, fp128 *%dst) {
91 ; CHECK: mxdb %f0, 0(%r2)
92 ; CHECK: std %f0, 0(%r3)
93 ; CHECK: std %f2, 8(%r3)
95 %ptr = getelementptr double, double *%base, i64 -1
96 %f2 = load double, double *%ptr
97 %f1x = fpext double %f1 to fp128
98 %f2x = fpext double %f2 to fp128
99 %res = call fp128 @llvm.experimental.constrained.fmul.f128(
100 fp128 %f1x, fp128 %f2x,
101 metadata !"round.dynamic",
102 metadata !"fpexcept.strict")
103 store fp128 %res, fp128 *%dst
107 ; Check that MXDB allows indices.
108 define void @f6(double %f1, double *%base, i64 %index, fp128 *%dst) {
110 ; CHECK: sllg %r1, %r3, 3
111 ; CHECK: mxdb %f0, 800(%r1,%r2)
112 ; CHECK: std %f0, 0(%r4)
113 ; CHECK: std %f2, 8(%r4)
115 %ptr1 = getelementptr double, double *%base, i64 %index
116 %ptr2 = getelementptr double, double *%ptr1, i64 100
117 %f2 = load double, double *%ptr2
118 %f1x = fpext double %f1 to fp128
119 %f2x = fpext double %f2 to fp128
120 %res = call fp128 @llvm.experimental.constrained.fmul.f128(
121 fp128 %f1x, fp128 %f2x,
122 metadata !"round.dynamic",
123 metadata !"fpexcept.strict")
124 store fp128 %res, fp128 *%dst
128 ; Check that multiplications of spilled values can use MXDB rather than MXDBR.
129 define double @f7(double *%ptr0) {
131 ; CHECK: brasl %r14, foo@PLT
132 ; CHECK: mxdb %f0, 160(%r15)
134 %ptr1 = getelementptr double, double *%ptr0, i64 2
135 %ptr2 = getelementptr double, double *%ptr0, i64 4
136 %ptr3 = getelementptr double, double *%ptr0, i64 6
137 %ptr4 = getelementptr double, double *%ptr0, i64 8
138 %ptr5 = getelementptr double, double *%ptr0, i64 10
139 %ptr6 = getelementptr double, double *%ptr0, i64 12
140 %ptr7 = getelementptr double, double *%ptr0, i64 14
141 %ptr8 = getelementptr double, double *%ptr0, i64 16
142 %ptr9 = getelementptr double, double *%ptr0, i64 18
143 %ptr10 = getelementptr double, double *%ptr0, i64 20
145 %val0 = load double, double *%ptr0
146 %val1 = load double, double *%ptr1
147 %val2 = load double, double *%ptr2
148 %val3 = load double, double *%ptr3
149 %val4 = load double, double *%ptr4
150 %val5 = load double, double *%ptr5
151 %val6 = load double, double *%ptr6
152 %val7 = load double, double *%ptr7
153 %val8 = load double, double *%ptr8
154 %val9 = load double, double *%ptr9
155 %val10 = load double, double *%ptr10
157 %frob0 = fadd double %val0, %val0
158 %frob1 = fadd double %val1, %val1
159 %frob2 = fadd double %val2, %val2
160 %frob3 = fadd double %val3, %val3
161 %frob4 = fadd double %val4, %val4
162 %frob5 = fadd double %val5, %val5
163 %frob6 = fadd double %val6, %val6
164 %frob7 = fadd double %val7, %val7
165 %frob8 = fadd double %val8, %val8
166 %frob9 = fadd double %val9, %val9
167 %frob10 = fadd double %val9, %val10
169 store double %frob0, double *%ptr0
170 store double %frob1, double *%ptr1
171 store double %frob2, double *%ptr2
172 store double %frob3, double *%ptr3
173 store double %frob4, double *%ptr4
174 store double %frob5, double *%ptr5
175 store double %frob6, double *%ptr6
176 store double %frob7, double *%ptr7
177 store double %frob8, double *%ptr8
178 store double %frob9, double *%ptr9
179 store double %frob10, double *%ptr10
181 %ret = call double @foo()
183 %accext0 = fpext double %ret to fp128
184 %ext0 = fpext double %frob0 to fp128
185 %mul0 = call fp128 @llvm.experimental.constrained.fmul.f128(
186 fp128 %accext0, fp128 %ext0,
187 metadata !"round.dynamic",
188 metadata !"fpexcept.strict")
189 %const0 = fpext double 1.01 to fp128
190 %extra0 = call fp128 @llvm.experimental.constrained.fmul.f128(
191 fp128 %mul0, fp128 %const0,
192 metadata !"round.dynamic",
193 metadata !"fpexcept.strict")
194 %trunc0 = fptrunc fp128 %extra0 to double
196 %accext1 = fpext double %trunc0 to fp128
197 %ext1 = fpext double %frob1 to fp128
198 %mul1 = call fp128 @llvm.experimental.constrained.fmul.f128(
199 fp128 %accext1, fp128 %ext1,
200 metadata !"round.dynamic",
201 metadata !"fpexcept.strict")
202 %const1 = fpext double 1.11 to fp128
203 %extra1 = call fp128 @llvm.experimental.constrained.fmul.f128(
204 fp128 %mul1, fp128 %const1,
205 metadata !"round.dynamic",
206 metadata !"fpexcept.strict")
207 %trunc1 = fptrunc fp128 %extra1 to double
209 %accext2 = fpext double %trunc1 to fp128
210 %ext2 = fpext double %frob2 to fp128
211 %mul2 = call fp128 @llvm.experimental.constrained.fmul.f128(
212 fp128 %accext2, fp128 %ext2,
213 metadata !"round.dynamic",
214 metadata !"fpexcept.strict")
215 %const2 = fpext double 1.21 to fp128
216 %extra2 = call fp128 @llvm.experimental.constrained.fmul.f128(
217 fp128 %mul2, fp128 %const2,
218 metadata !"round.dynamic",
219 metadata !"fpexcept.strict")
220 %trunc2 = fptrunc fp128 %extra2 to double
222 %accext3 = fpext double %trunc2 to fp128
223 %ext3 = fpext double %frob3 to fp128
224 %mul3 = call fp128 @llvm.experimental.constrained.fmul.f128(
225 fp128 %accext3, fp128 %ext3,
226 metadata !"round.dynamic",
227 metadata !"fpexcept.strict")
228 %const3 = fpext double 1.31 to fp128
229 %extra3 = call fp128 @llvm.experimental.constrained.fmul.f128(
230 fp128 %mul3, fp128 %const3,
231 metadata !"round.dynamic",
232 metadata !"fpexcept.strict")
233 %trunc3 = fptrunc fp128 %extra3 to double
235 %accext4 = fpext double %trunc3 to fp128
236 %ext4 = fpext double %frob4 to fp128
237 %mul4 = call fp128 @llvm.experimental.constrained.fmul.f128(
238 fp128 %accext4, fp128 %ext4,
239 metadata !"round.dynamic",
240 metadata !"fpexcept.strict")
241 %const4 = fpext double 1.41 to fp128
242 %extra4 = call fp128 @llvm.experimental.constrained.fmul.f128(
243 fp128 %mul4, fp128 %const4,
244 metadata !"round.dynamic",
245 metadata !"fpexcept.strict")
246 %trunc4 = fptrunc fp128 %extra4 to double
248 %accext5 = fpext double %trunc4 to fp128
249 %ext5 = fpext double %frob5 to fp128
250 %mul5 = call fp128 @llvm.experimental.constrained.fmul.f128(
251 fp128 %accext5, fp128 %ext5,
252 metadata !"round.dynamic",
253 metadata !"fpexcept.strict")
254 %const5 = fpext double 1.51 to fp128
255 %extra5 = call fp128 @llvm.experimental.constrained.fmul.f128(
256 fp128 %mul5, fp128 %const5,
257 metadata !"round.dynamic",
258 metadata !"fpexcept.strict")
259 %trunc5 = fptrunc fp128 %extra5 to double
261 %accext6 = fpext double %trunc5 to fp128
262 %ext6 = fpext double %frob6 to fp128
263 %mul6 = call fp128 @llvm.experimental.constrained.fmul.f128(
264 fp128 %accext6, fp128 %ext6,
265 metadata !"round.dynamic",
266 metadata !"fpexcept.strict")
267 %const6 = fpext double 1.61 to fp128
268 %extra6 = call fp128 @llvm.experimental.constrained.fmul.f128(
269 fp128 %mul6, fp128 %const6,
270 metadata !"round.dynamic",
271 metadata !"fpexcept.strict")
272 %trunc6 = fptrunc fp128 %extra6 to double
274 %accext7 = fpext double %trunc6 to fp128
275 %ext7 = fpext double %frob7 to fp128
276 %mul7 = call fp128 @llvm.experimental.constrained.fmul.f128(
277 fp128 %accext7, fp128 %ext7,
278 metadata !"round.dynamic",
279 metadata !"fpexcept.strict")
280 %const7 = fpext double 1.71 to fp128
281 %extra7 = call fp128 @llvm.experimental.constrained.fmul.f128(
282 fp128 %mul7, fp128 %const7,
283 metadata !"round.dynamic",
284 metadata !"fpexcept.strict")
285 %trunc7 = fptrunc fp128 %extra7 to double
287 %accext8 = fpext double %trunc7 to fp128
288 %ext8 = fpext double %frob8 to fp128
289 %mul8 = call fp128 @llvm.experimental.constrained.fmul.f128(
290 fp128 %accext8, fp128 %ext8,
291 metadata !"round.dynamic",
292 metadata !"fpexcept.strict")
293 %const8 = fpext double 1.81 to fp128
294 %extra8 = call fp128 @llvm.experimental.constrained.fmul.f128(
295 fp128 %mul8, fp128 %const8,
296 metadata !"round.dynamic",
297 metadata !"fpexcept.strict")
298 %trunc8 = fptrunc fp128 %extra8 to double
300 %accext9 = fpext double %trunc8 to fp128
301 %ext9 = fpext double %frob9 to fp128
302 %mul9 = call fp128 @llvm.experimental.constrained.fmul.f128(
303 fp128 %accext9, fp128 %ext9,
304 metadata !"round.dynamic",
305 metadata !"fpexcept.strict")
306 %const9 = fpext double 1.91 to fp128
307 %extra9 = call fp128 @llvm.experimental.constrained.fmul.f128(
308 fp128 %mul9, fp128 %const9,
309 metadata !"round.dynamic",
310 metadata !"fpexcept.strict")
311 %trunc9 = fptrunc fp128 %extra9 to double