1 ; RUN: llc < %s -mtriple=armv7-eabi -mattr=+neon,+vfp4 -fp-contract=fast | FileCheck %s
2 ; Check generated fused MAC and MLS.
4 define double @fusedMACTest1(double %d1, double %d2, double %d3) {
5 ;CHECK-LABEL: fusedMACTest1:
7 %1 = fmul double %d1, %d2
8 %2 = fadd double %1, %d3
12 define float @fusedMACTest2(float %f1, float %f2, float %f3) {
13 ;CHECK-LABEL: fusedMACTest2:
15 %1 = fmul float %f1, %f2
16 %2 = fadd float %1, %f3
20 define double @fusedMACTest3(double %d1, double %d2, double %d3) {
21 ;CHECK-LABEL: fusedMACTest3:
23 %1 = fmul double %d2, %d3
24 %2 = fsub double %d1, %1
28 define float @fusedMACTest4(float %f1, float %f2, float %f3) {
29 ;CHECK-LABEL: fusedMACTest4:
31 %1 = fmul float %f2, %f3
32 %2 = fsub float %f1, %1
36 define double @fusedMACTest5(double %d1, double %d2, double %d3) {
37 ;CHECK-LABEL: fusedMACTest5:
39 %1 = fmul double %d1, %d2
40 %2 = fsub double -0.0, %1
41 %3 = fsub double %2, %d3
45 define float @fusedMACTest6(float %f1, float %f2, float %f3) {
46 ;CHECK-LABEL: fusedMACTest6:
48 %1 = fmul float %f1, %f2
49 %2 = fsub float -0.0, %1
50 %3 = fsub float %2, %f3
54 define double @fusedMACTest7(double %d1, double %d2, double %d3) {
55 ;CHECK-LABEL: fusedMACTest7:
57 %1 = fmul double %d1, %d2
58 %2 = fsub double %1, %d3
62 define float @fusedMACTest8(float %f1, float %f2, float %f3) {
63 ;CHECK-LABEL: fusedMACTest8:
65 %1 = fmul float %f1, %f2
66 %2 = fsub float %1, %f3
70 define <2 x float> @fusedMACTest9(<2 x float> %a, <2 x float> %b) {
71 ;CHECK-LABEL: fusedMACTest9:
73 %mul = fmul <2 x float> %a, %b
74 %add = fadd <2 x float> %mul, %a
78 define <2 x float> @fusedMACTest10(<2 x float> %a, <2 x float> %b) {
79 ;CHECK-LABEL: fusedMACTest10:
81 %mul = fmul <2 x float> %a, %b
82 %sub = fsub <2 x float> %a, %mul
86 define <4 x float> @fusedMACTest11(<4 x float> %a, <4 x float> %b) {
87 ;CHECK-LABEL: fusedMACTest11:
89 %mul = fmul <4 x float> %a, %b
90 %add = fadd <4 x float> %mul, %a
94 define <4 x float> @fusedMACTest12(<4 x float> %a, <4 x float> %b) {
95 ;CHECK-LABEL: fusedMACTest12:
97 %mul = fmul <4 x float> %a, %b
98 %sub = fsub <4 x float> %a, %mul
102 define float @test_fma_f32(float %a, float %b, float %c) nounwind readnone ssp {
104 ; CHECK: test_fma_f32
106 %tmp1 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
110 define double @test_fma_f64(double %a, double %b, double %c) nounwind readnone ssp {
112 ; CHECK: test_fma_f64
114 %tmp1 = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone
118 define <2 x float> @test_fma_v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind readnone ssp {
120 ; CHECK: test_fma_v2f32
122 %tmp1 = tail call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c) nounwind
123 ret <2 x float> %tmp1
126 define double @test_fms_f64(double %a, double %b, double %c) nounwind readnone ssp {
128 ; CHECK: test_fms_f64
130 %tmp1 = fsub double -0.0, %a
131 %tmp2 = tail call double @llvm.fma.f64(double %tmp1, double %b, double %c) nounwind readnone
135 define double @test_fms_f64_2(double %a, double %b, double %c) nounwind readnone ssp {
137 ; CHECK: test_fms_f64_2
139 %tmp1 = fsub double -0.0, %b
140 %tmp2 = tail call double @llvm.fma.f64(double %a, double %tmp1, double %c) nounwind readnone
144 define float @test_fnms_f32(float %a, float %b, float* %c) nounwind readnone ssp {
145 ; CHECK: test_fnms_f32
147 %tmp1 = load float, float* %c, align 4
148 %tmp2 = fsub float -0.0, %tmp1
149 %tmp3 = tail call float @llvm.fma.f32(float %a, float %b, float %tmp2) nounwind readnone
153 define double @test_fnms_f64(double %a, double %b, double %c) nounwind readnone ssp {
155 ; CHECK: test_fnms_f64
157 %tmp1 = fsub double -0.0, %a
158 %tmp2 = tail call double @llvm.fma.f64(double %tmp1, double %b, double %c) nounwind readnone
159 %tmp3 = fsub double -0.0, %tmp2
163 define double @test_fnms_f64_2(double %a, double %b, double %c) nounwind readnone ssp {
165 ; CHECK: test_fnms_f64_2
167 %tmp1 = fsub double -0.0, %b
168 %tmp2 = tail call double @llvm.fma.f64(double %a, double %tmp1, double %c) nounwind readnone
169 %tmp3 = fsub double -0.0, %tmp2
173 define double @test_fnma_f64(double %a, double %b, double %c) nounwind readnone ssp {
175 ; CHECK: test_fnma_f64
177 %tmp1 = tail call double @llvm.fma.f64(double %a, double %b, double %c) nounwind readnone
178 %tmp2 = fsub double -0.0, %tmp1
182 define double @test_fnma_f64_2(double %a, double %b, double %c) nounwind readnone ssp {
184 ; CHECK: test_fnma_f64_2
186 %tmp1 = fsub double -0.0, %a
187 %tmp2 = fsub double -0.0, %c
188 %tmp3 = tail call double @llvm.fma.f64(double %tmp1, double %b, double %tmp2) nounwind readnone
192 define float @test_fma_const_fold(float %a, float %b) nounwind {
193 ; CHECK: test_fma_const_fold
197 %ret = call float @llvm.fma.f32(float %a, float 1.0, float %b)
201 define float @test_fma_canonicalize(float %a, float %b) nounwind {
202 ; CHECK: test_fma_canonicalize
203 ; CHECK: vmov.f32 [[R1:s[0-9]+]], #2.000000e+00
204 ; CHECK: vfma.f32 {{s[0-9]+}}, {{s[0-9]+}}, [[R1]]
205 %ret = call float @llvm.fma.f32(float 2.0, float %a, float %b)
209 ; Check that very wide vector fma's can be split into legal fma's.
210 define void @test_fma_v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %c, <8 x float>* %p) nounwind readnone ssp {
211 ; CHECK: test_fma_v8f32
215 %call = tail call <8 x float> @llvm.fma.v8f32(<8 x float> %a, <8 x float> %b, <8 x float> %c) nounwind readnone
216 store <8 x float> %call, <8 x float>* %p, align 16
221 declare float @llvm.fma.f32(float, float, float) nounwind readnone
222 declare double @llvm.fma.f64(double, double, double) nounwind readnone
223 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) nounwind readnone
224 declare <8 x float> @llvm.fma.v8f32(<8 x float>, <8 x float>, <8 x float>) nounwind readnone