1 ; RUN: llc -march=mips -mattr=+msa,+fp64,+mips32r2 < %s | FileCheck %s
2 ; RUN: llc -march=mipsel -mattr=+msa,+fp64,+mips32r2 < %s | FileCheck %s
4 define void @add_v4f32(<4 x float>* %c, <4 x float>* %a, <4 x float>* %b) nounwind {
7 %1 = load <4 x float>, <4 x float>* %a
8 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
9 %2 = load <4 x float>, <4 x float>* %b
10 ; CHECK-DAG: ld.w [[R2:\$w[0-9]+]], 0($6)
11 %3 = fadd <4 x float> %1, %2
12 ; CHECK-DAG: fadd.w [[R3:\$w[0-9]+]], [[R1]], [[R2]]
13 store <4 x float> %3, <4 x float>* %c
14 ; CHECK-DAG: st.w [[R3]], 0($4)
17 ; CHECK: .size add_v4f32
20 define void @add_v2f64(<2 x double>* %c, <2 x double>* %a, <2 x double>* %b) nounwind {
23 %1 = load <2 x double>, <2 x double>* %a
24 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
25 %2 = load <2 x double>, <2 x double>* %b
26 ; CHECK-DAG: ld.d [[R2:\$w[0-9]+]], 0($6)
27 %3 = fadd <2 x double> %1, %2
28 ; CHECK-DAG: fadd.d [[R3:\$w[0-9]+]], [[R1]], [[R2]]
29 store <2 x double> %3, <2 x double>* %c
30 ; CHECK-DAG: st.d [[R3]], 0($4)
33 ; CHECK: .size add_v2f64
36 define void @sub_v4f32(<4 x float>* %c, <4 x float>* %a, <4 x float>* %b) nounwind {
39 %1 = load <4 x float>, <4 x float>* %a
40 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
41 %2 = load <4 x float>, <4 x float>* %b
42 ; CHECK-DAG: ld.w [[R2:\$w[0-9]+]], 0($6)
43 %3 = fsub <4 x float> %1, %2
44 ; CHECK-DAG: fsub.w [[R3:\$w[0-9]+]], [[R1]], [[R2]]
45 store <4 x float> %3, <4 x float>* %c
46 ; CHECK-DAG: st.w [[R3]], 0($4)
49 ; CHECK: .size sub_v4f32
52 define void @sub_v2f64(<2 x double>* %c, <2 x double>* %a, <2 x double>* %b) nounwind {
55 %1 = load <2 x double>, <2 x double>* %a
56 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
57 %2 = load <2 x double>, <2 x double>* %b
58 ; CHECK-DAG: ld.d [[R2:\$w[0-9]+]], 0($6)
59 %3 = fsub <2 x double> %1, %2
60 ; CHECK-DAG: fsub.d [[R3:\$w[0-9]+]], [[R1]], [[R2]]
61 store <2 x double> %3, <2 x double>* %c
62 ; CHECK-DAG: st.d [[R3]], 0($4)
65 ; CHECK: .size sub_v2f64
68 define void @mul_v4f32(<4 x float>* %c, <4 x float>* %a, <4 x float>* %b) nounwind {
71 %1 = load <4 x float>, <4 x float>* %a
72 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
73 %2 = load <4 x float>, <4 x float>* %b
74 ; CHECK-DAG: ld.w [[R2:\$w[0-9]+]], 0($6)
75 %3 = fmul <4 x float> %1, %2
76 ; CHECK-DAG: fmul.w [[R3:\$w[0-9]+]], [[R1]], [[R2]]
77 store <4 x float> %3, <4 x float>* %c
78 ; CHECK-DAG: st.w [[R3]], 0($4)
81 ; CHECK: .size mul_v4f32
84 define void @mul_v2f64(<2 x double>* %c, <2 x double>* %a, <2 x double>* %b) nounwind {
87 %1 = load <2 x double>, <2 x double>* %a
88 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
89 %2 = load <2 x double>, <2 x double>* %b
90 ; CHECK-DAG: ld.d [[R2:\$w[0-9]+]], 0($6)
91 %3 = fmul <2 x double> %1, %2
92 ; CHECK-DAG: fmul.d [[R3:\$w[0-9]+]], [[R1]], [[R2]]
93 store <2 x double> %3, <2 x double>* %c
94 ; CHECK-DAG: st.d [[R3]], 0($4)
97 ; CHECK: .size mul_v2f64
100 define void @fma_v4f32(<4 x float>* %d, <4 x float>* %a, <4 x float>* %b,
101 <4 x float>* %c) nounwind {
104 %1 = load <4 x float>, <4 x float>* %a
105 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
106 %2 = load <4 x float>, <4 x float>* %b
107 ; CHECK-DAG: ld.w [[R2:\$w[0-9]+]], 0($6)
108 %3 = load <4 x float>, <4 x float>* %c
109 ; CHECK-DAG: ld.w [[R3:\$w[0-9]+]], 0($7)
110 %4 = tail call <4 x float> @llvm.fma.v4f32 (<4 x float> %1, <4 x float> %2,
112 ; CHECK-DAG: fmadd.w [[R1]], [[R2]], [[R3]]
113 store <4 x float> %4, <4 x float>* %d
114 ; CHECK-DAG: st.w [[R1]], 0($4)
117 ; CHECK: .size fma_v4f32
120 define void @fma_v2f64(<2 x double>* %d, <2 x double>* %a, <2 x double>* %b,
121 <2 x double>* %c) nounwind {
124 %1 = load <2 x double>, <2 x double>* %a
125 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
126 %2 = load <2 x double>, <2 x double>* %b
127 ; CHECK-DAG: ld.d [[R2:\$w[0-9]+]], 0($6)
128 %3 = load <2 x double>, <2 x double>* %c
129 ; CHECK-DAG: ld.d [[R3:\$w[0-9]+]], 0($7)
130 %4 = tail call <2 x double> @llvm.fma.v2f64 (<2 x double> %1, <2 x double> %2,
132 ; CHECK-DAG: fmadd.d [[R1]], [[R2]], [[R3]]
133 store <2 x double> %4, <2 x double>* %d
134 ; CHECK-DAG: st.d [[R1]], 0($4)
137 ; CHECK: .size fma_v2f64
140 define void @fmlu_fsub_v4f32(<4 x float>* %d, <4 x float>* %a, <4 x float>* %b,
141 <4 x float>* %c) nounwind {
142 ; CHECK: fmlu_fsub_v4f32:
144 %1 = load <4 x float>, <4 x float>* %b
145 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($6)
146 %2 = load <4 x float>, <4 x float>* %c
147 ; CHECK-DAG: ld.w [[R2:\$w[0-9]+]], 0($7)
148 %3 = fmul <4 x float> %1, %2
149 ; CHECK-DAG: fmul.w [[R2]], [[R1]], [[R2]]
150 %4 = load <4 x float>, <4 x float>* %a
151 ; CHECK-DAG: ld.w [[R3:\$w[0-9]+]], 0($5)
152 %5 = fsub <4 x float> %4, %3
153 ; CHECK-DAG: fsub.w [[R2]], [[R3]], [[R2]]
154 store <4 x float> %5, <4 x float>* %d
155 ; CHECK-DAG: st.w [[R2]], 0($4)
158 ; CHECK: .size fmlu_fsub_v4f32
161 define void @fmul_fsub_v2f64(<2 x double>* %d, <2 x double>* %a, <2 x double>* %b,
162 <2 x double>* %c) nounwind {
163 ; CHECK: fmul_fsub_v2f64:
165 %1 = load <2 x double>, <2 x double>* %b
166 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($7)
167 %2 = load <2 x double>, <2 x double>* %c
168 ; CHECK-DAG: ld.d [[R2:\$w[0-9]+]], 0($6)
169 %3 = fmul <2 x double> %1, %2
170 ; CHECK-DAG: fmul.d [[R1]], [[R2]], [[R1]]
171 %4 = load <2 x double>, <2 x double>* %a
172 ; CHECK-DAG: ld.d [[R3:\$w[0-9]+]], 0($5)
173 %5 = fsub <2 x double> %4, %3
174 ; CHECK-DAG: fsub.d [[R1]], [[R3]], [[R1]]
175 store <2 x double> %5, <2 x double>* %d
176 ; CHECK-DAG: st.d [[R1]], 0($4)
179 ; CHECK: .size fmul_fsub_v2f64
182 define void @fdiv_v4f32(<4 x float>* %c, <4 x float>* %a, <4 x float>* %b) nounwind {
185 %1 = load <4 x float>, <4 x float>* %a
186 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
187 %2 = load <4 x float>, <4 x float>* %b
188 ; CHECK-DAG: ld.w [[R2:\$w[0-9]+]], 0($6)
189 %3 = fdiv <4 x float> %1, %2
190 ; CHECK-DAG: fdiv.w [[R3:\$w[0-9]+]], [[R1]], [[R2]]
191 store <4 x float> %3, <4 x float>* %c
192 ; CHECK-DAG: st.w [[R3]], 0($4)
195 ; CHECK: .size fdiv_v4f32
198 define void @fdiv_v2f64(<2 x double>* %c, <2 x double>* %a, <2 x double>* %b) nounwind {
201 %1 = load <2 x double>, <2 x double>* %a
202 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
203 %2 = load <2 x double>, <2 x double>* %b
204 ; CHECK-DAG: ld.d [[R2:\$w[0-9]+]], 0($6)
205 %3 = fdiv <2 x double> %1, %2
206 ; CHECK-DAG: fdiv.d [[R3:\$w[0-9]+]], [[R1]], [[R2]]
207 store <2 x double> %3, <2 x double>* %c
208 ; CHECK-DAG: st.d [[R3]], 0($4)
211 ; CHECK: .size fdiv_v2f64
214 define void @fabs_v4f32(<4 x float>* %c, <4 x float>* %a) nounwind {
217 %1 = load <4 x float>, <4 x float>* %a
218 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
219 %2 = tail call <4 x float> @llvm.fabs.v4f32 (<4 x float> %1)
220 ; CHECK-DAG: fmax_a.w [[R3:\$w[0-9]+]], [[R1]], [[R1]]
221 store <4 x float> %2, <4 x float>* %c
222 ; CHECK-DAG: st.w [[R3]], 0($4)
225 ; CHECK: .size fabs_v4f32
228 define void @fabs_v2f64(<2 x double>* %c, <2 x double>* %a) nounwind {
231 %1 = load <2 x double>, <2 x double>* %a
232 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
233 %2 = tail call <2 x double> @llvm.fabs.v2f64 (<2 x double> %1)
234 ; CHECK-DAG: fmax_a.d [[R3:\$w[0-9]+]], [[R1]], [[R1]]
235 store <2 x double> %2, <2 x double>* %c
236 ; CHECK-DAG: st.d [[R3]], 0($4)
239 ; CHECK: .size fabs_v2f64
242 define void @fexp2_v4f32(<4 x float>* %c, <4 x float>* %a) nounwind {
243 ; CHECK: fexp2_v4f32:
245 %1 = load <4 x float>, <4 x float>* %a
246 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
247 %2 = tail call <4 x float> @llvm.exp2.v4f32 (<4 x float> %1)
248 ; CHECK-DAG: ldi.w [[R3:\$w[0-9]+]], 1
249 ; CHECK-DAG: ffint_u.w [[R4:\$w[0-9]+]], [[R3]]
250 ; CHECK-DAG: fexp2.w [[R4:\$w[0-9]+]], [[R3]], [[R1]]
251 store <4 x float> %2, <4 x float>* %c
252 ; CHECK-DAG: st.w [[R4]], 0($4)
255 ; CHECK: .size fexp2_v4f32
258 define void @fexp2_v2f64(<2 x double>* %c, <2 x double>* %a) nounwind {
259 ; CHECK: fexp2_v2f64:
261 %1 = load <2 x double>, <2 x double>* %a
262 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
263 %2 = tail call <2 x double> @llvm.exp2.v2f64 (<2 x double> %1)
264 ; CHECK-DAG: ldi.d [[R3:\$w[0-9]+]], 1
265 ; CHECK-DAG: ffint_u.d [[R4:\$w[0-9]+]], [[R3]]
266 ; CHECK-DAG: fexp2.d [[R4:\$w[0-9]+]], [[R3]], [[R1]]
267 store <2 x double> %2, <2 x double>* %c
268 ; CHECK-DAG: st.d [[R4]], 0($4)
271 ; CHECK: .size fexp2_v2f64
274 define void @fexp2_v4f32_2(<4 x float>* %c, <4 x float>* %a) nounwind {
275 ; CHECK: fexp2_v4f32_2:
277 %1 = load <4 x float>, <4 x float>* %a
278 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
279 %2 = tail call <4 x float> @llvm.exp2.v4f32 (<4 x float> %1)
280 %3 = fmul <4 x float> <float 2.0, float 2.0, float 2.0, float 2.0>, %2
281 ; CHECK-DAG: ldi.w [[R3:\$w[0-9]+]], 1
282 ; CHECK-DAG: ffint_u.w [[R4:\$w[0-9]+]], [[R3]]
283 ; CHECK-DAG: fexp2.w [[R5:\$w[0-9]+]], [[R4]], [[R1]]
284 store <4 x float> %3, <4 x float>* %c
285 ; CHECK-DAG: st.w [[R5]], 0($4)
288 ; CHECK: .size fexp2_v4f32_2
291 define void @fexp2_v2f64_2(<2 x double>* %c, <2 x double>* %a) nounwind {
292 ; CHECK: fexp2_v2f64_2:
294 %1 = load <2 x double>, <2 x double>* %a
295 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
296 %2 = tail call <2 x double> @llvm.exp2.v2f64 (<2 x double> %1)
297 %3 = fmul <2 x double> <double 2.0, double 2.0>, %2
298 ; CHECK-DAG: ldi.d [[R2:\$w[0-9]+]], 1
299 ; CHECK-DAG: ffint_u.d [[R3:\$w[0-9]+]], [[R2]]
300 ; CHECK-DAG: fexp2.d [[R4:\$w[0-9]+]], [[R3]], [[R1]]
301 store <2 x double> %3, <2 x double>* %c
302 ; CHECK-DAG: st.d [[R4]], 0($4)
305 ; CHECK: .size fexp2_v2f64_2
308 define void @fsqrt_v4f32(<4 x float>* %c, <4 x float>* %a) nounwind {
309 ; CHECK: fsqrt_v4f32:
311 %1 = load <4 x float>, <4 x float>* %a
312 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
313 %2 = tail call <4 x float> @llvm.sqrt.v4f32 (<4 x float> %1)
314 ; CHECK-DAG: fsqrt.w [[R3:\$w[0-9]+]], [[R1]]
315 store <4 x float> %2, <4 x float>* %c
316 ; CHECK-DAG: st.w [[R3]], 0($4)
319 ; CHECK: .size fsqrt_v4f32
322 define void @fsqrt_v2f64(<2 x double>* %c, <2 x double>* %a) nounwind {
323 ; CHECK: fsqrt_v2f64:
325 %1 = load <2 x double>, <2 x double>* %a
326 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
327 %2 = tail call <2 x double> @llvm.sqrt.v2f64 (<2 x double> %1)
328 ; CHECK-DAG: fsqrt.d [[R3:\$w[0-9]+]], [[R1]]
329 store <2 x double> %2, <2 x double>* %c
330 ; CHECK-DAG: st.d [[R3]], 0($4)
333 ; CHECK: .size fsqrt_v2f64
336 define void @ffint_u_v4f32(<4 x float>* %c, <4 x i32>* %a) nounwind {
337 ; CHECK: ffint_u_v4f32:
339 %1 = load <4 x i32>, <4 x i32>* %a
340 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
341 %2 = uitofp <4 x i32> %1 to <4 x float>
342 ; CHECK-DAG: ffint_u.w [[R3:\$w[0-9]+]], [[R1]]
343 store <4 x float> %2, <4 x float>* %c
344 ; CHECK-DAG: st.w [[R3]], 0($4)
347 ; CHECK: .size ffint_u_v4f32
350 define void @ffint_u_v2f64(<2 x double>* %c, <2 x i64>* %a) nounwind {
351 ; CHECK: ffint_u_v2f64:
353 %1 = load <2 x i64>, <2 x i64>* %a
354 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
355 %2 = uitofp <2 x i64> %1 to <2 x double>
356 ; CHECK-DAG: ffint_u.d [[R3:\$w[0-9]+]], [[R1]]
357 store <2 x double> %2, <2 x double>* %c
358 ; CHECK-DAG: st.d [[R3]], 0($4)
361 ; CHECK: .size ffint_u_v2f64
364 define void @ffint_s_v4f32(<4 x float>* %c, <4 x i32>* %a) nounwind {
365 ; CHECK: ffint_s_v4f32:
367 %1 = load <4 x i32>, <4 x i32>* %a
368 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
369 %2 = sitofp <4 x i32> %1 to <4 x float>
370 ; CHECK-DAG: ffint_s.w [[R3:\$w[0-9]+]], [[R1]]
371 store <4 x float> %2, <4 x float>* %c
372 ; CHECK-DAG: st.w [[R3]], 0($4)
375 ; CHECK: .size ffint_s_v4f32
378 define void @ffint_s_v2f64(<2 x double>* %c, <2 x i64>* %a) nounwind {
379 ; CHECK: ffint_s_v2f64:
381 %1 = load <2 x i64>, <2 x i64>* %a
382 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
383 %2 = sitofp <2 x i64> %1 to <2 x double>
384 ; CHECK-DAG: ffint_s.d [[R3:\$w[0-9]+]], [[R1]]
385 store <2 x double> %2, <2 x double>* %c
386 ; CHECK-DAG: st.d [[R3]], 0($4)
389 ; CHECK: .size ffint_s_v2f64
392 define void @ftrunc_u_v4f32(<4 x i32>* %c, <4 x float>* %a) nounwind {
393 ; CHECK: ftrunc_u_v4f32:
395 %1 = load <4 x float>, <4 x float>* %a
396 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
397 %2 = fptoui <4 x float> %1 to <4 x i32>
398 ; CHECK-DAG: ftrunc_u.w [[R3:\$w[0-9]+]], [[R1]]
399 store <4 x i32> %2, <4 x i32>* %c
400 ; CHECK-DAG: st.w [[R3]], 0($4)
403 ; CHECK: .size ftrunc_u_v4f32
406 define void @ftrunc_u_v2f64(<2 x i64>* %c, <2 x double>* %a) nounwind {
407 ; CHECK: ftrunc_u_v2f64:
409 %1 = load <2 x double>, <2 x double>* %a
410 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
411 %2 = fptoui <2 x double> %1 to <2 x i64>
412 ; CHECK-DAG: ftrunc_u.d [[R3:\$w[0-9]+]], [[R1]]
413 store <2 x i64> %2, <2 x i64>* %c
414 ; CHECK-DAG: st.d [[R3]], 0($4)
417 ; CHECK: .size ftrunc_u_v2f64
420 define void @ftrunc_s_v4f32(<4 x i32>* %c, <4 x float>* %a) nounwind {
421 ; CHECK: ftrunc_s_v4f32:
423 %1 = load <4 x float>, <4 x float>* %a
424 ; CHECK-DAG: ld.w [[R1:\$w[0-9]+]], 0($5)
425 %2 = fptosi <4 x float> %1 to <4 x i32>
426 ; CHECK-DAG: ftrunc_s.w [[R3:\$w[0-9]+]], [[R1]]
427 store <4 x i32> %2, <4 x i32>* %c
428 ; CHECK-DAG: st.w [[R3]], 0($4)
431 ; CHECK: .size ftrunc_s_v4f32
434 define void @ftrunc_s_v2f64(<2 x i64>* %c, <2 x double>* %a) nounwind {
435 ; CHECK: ftrunc_s_v2f64:
437 %1 = load <2 x double>, <2 x double>* %a
438 ; CHECK-DAG: ld.d [[R1:\$w[0-9]+]], 0($5)
439 %2 = fptosi <2 x double> %1 to <2 x i64>
440 ; CHECK-DAG: ftrunc_s.d [[R3:\$w[0-9]+]], [[R1]]
441 store <2 x i64> %2, <2 x i64>* %c
442 ; CHECK-DAG: st.d [[R3]], 0($4)
445 ; CHECK: .size ftrunc_s_v2f64
448 declare <4 x float> @llvm.fabs.v4f32(<4 x float> %Val)
449 declare <2 x double> @llvm.fabs.v2f64(<2 x double> %Val)
450 declare <4 x float> @llvm.exp2.v4f32(<4 x float> %val)
451 declare <2 x double> @llvm.exp2.v2f64(<2 x double> %val)
452 declare <4 x float> @llvm.fma.v4f32(<4 x float> %a, <4 x float> %b,
454 declare <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> %b,
456 declare <4 x float> @llvm.sqrt.v4f32(<4 x float> %Val)
457 declare <2 x double> @llvm.sqrt.v2f64(<2 x double> %Val)