xref: /llvm-project/llvm/test/CodeGen/Mips/fp-contract.ll (revision ae26f50aea4ef1a6c7058019f0db11a91bbcdade)
1; Test that the compiled does not fuse fmul and fadd into fmadd when no -fp-contract=fast
2; option is set (the same applies for fmul, fsub and fmsub).
3
4; RUN: llc -mtriple=mipsel -mattr=+msa,+fp64,+mips32r2 < %s \
5; RUN:   | FileCheck %s --check-prefixes=CHECK-CONTRACT-OFF
6; RUN: llc -mtriple=mipsel -mattr=+msa,+fp64,+mips32r2 -fp-contract=off < %s \
7; RUN:   | FileCheck %s --check-prefixes=CHECK-CONTRACT-OFF
8; RUN: llc -mtriple=mips -mattr=+msa,+fp64,+mips32r2 -fp-contract=fast < %s \
9; RUN:   | FileCheck %s --check-prefixes=CHECK-CONTRACT-FAST
10
11declare <4 x float> @llvm.mips.fmul.w(<4 x float>, <4 x float>)
12declare <4 x float> @llvm.mips.fadd.w(<4 x float>, <4 x float>)
13declare <4 x float> @llvm.mips.fsub.w(<4 x float>, <4 x float>)
14
15define void @foo(ptr %agg.result, ptr %acc, ptr %a, ptr %b) {
16entry:
17  %0 = load <4 x float>, ptr %a, align 16
18  %1 = load <4 x float>, ptr %b, align 16
19  %2 = call <4 x float> @llvm.mips.fmul.w(<4 x float> %0, <4 x float> %1)
20  %3 = load <4 x float>, ptr %acc, align 16
21  %4 = call <4 x float> @llvm.mips.fadd.w(<4 x float> %3, <4 x float> %2)
22  store <4 x float> %4, ptr %agg.result, align 16
23  ret void
24  ; CHECK-CONTRACT-OFF: fmul.w
25  ; CHECK-CONTRACT-OFF: fadd.w
26  ; CHECK-CONTRACT-FAST: fmadd.w
27}
28
29define void @boo(ptr %agg.result, ptr %acc, ptr %a, ptr %b) {
30entry:
31  %0 = load <4 x float>, ptr %a, align 16
32  %1 = load <4 x float>, ptr %b, align 16
33  %2 = call <4 x float> @llvm.mips.fmul.w(<4 x float> %0, <4 x float> %1)
34  %3 = load <4 x float>, ptr %acc, align 16
35  %4 = call <4 x float> @llvm.mips.fsub.w(<4 x float> %3, <4 x float> %2)
36  store <4 x float> %4, ptr %agg.result, align 16
37  ret void
38  ; CHECK-CONTRACT-OFF: fmul.w
39  ; CHECK-CONTRACT-OFF: fsub.w
40  ; CHECK-CONTRACT-FAST: fmsub.w
41}
42