1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple powerpc64le -verify-machineinstrs \
3 ; RUN: | FileCheck -check-prefix=VSX %s
4 ; RUN: llc < %s -mtriple powerpc64le -verify-machineinstrs -mattr=-vsx \
5 ; RUN: | FileCheck -check-prefix=NO-VSX %s
7 define double @test_mul_sub_f64(double %a, double %b, double %c) {
8 ; VSX-LABEL: test_mul_sub_f64:
9 ; VSX: # %bb.0: # %entry
10 ; VSX-NEXT: xsnegdp 0, 2
11 ; VSX-NEXT: xsmaddadp 1, 0, 3
14 ; NO-VSX-LABEL: test_mul_sub_f64:
15 ; NO-VSX: # %bb.0: # %entry
16 ; NO-VSX-NEXT: fneg 0, 2
17 ; NO-VSX-NEXT: fmadd 1, 0, 3, 1
20 %0 = fmul contract reassoc double %b, %c
21 %1 = fsub contract reassoc double %a, %0
25 define double @test_2mul_sub_f64(double %a, double %b, double %c, double %d) {
26 ; VSX-LABEL: test_2mul_sub_f64:
27 ; VSX: # %bb.0: # %entry
28 ; VSX-NEXT: xsmuldp 0, 3, 4
29 ; VSX-NEXT: xsmsubadp 0, 1, 2
33 ; NO-VSX-LABEL: test_2mul_sub_f64:
34 ; NO-VSX: # %bb.0: # %entry
35 ; NO-VSX-NEXT: fmul 0, 3, 4
36 ; NO-VSX-NEXT: fmsub 1, 1, 2, 0
39 %0 = fmul contract reassoc double %a, %b
40 %1 = fmul contract reassoc double %c, %d
41 %2 = fsub contract reassoc double %0, %1
45 define double @test_neg_fma_f64(double %a, double %b, double %c) {
46 ; VSX-LABEL: test_neg_fma_f64:
47 ; VSX: # %bb.0: # %entry
48 ; VSX-NEXT: xsnegdp 0, 1
49 ; VSX-NEXT: xsmaddadp 3, 0, 2
53 ; NO-VSX-LABEL: test_neg_fma_f64:
54 ; NO-VSX: # %bb.0: # %entry
55 ; NO-VSX-NEXT: fneg 0, 1
56 ; NO-VSX-NEXT: fmadd 1, 0, 2, 3
59 %0 = fsub contract reassoc double -0.0, %a
60 %1 = call contract reassoc double @llvm.fma.f64(double %0, double %b,
65 define float @test_mul_sub_f32(float %a, float %b, float %c) {
66 ; VSX-LABEL: test_mul_sub_f32:
67 ; VSX: # %bb.0: # %entry
68 ; VSX-NEXT: xsnegdp 0, 2
69 ; VSX-NEXT: xsmaddasp 1, 0, 3
72 ; NO-VSX-LABEL: test_mul_sub_f32:
73 ; NO-VSX: # %bb.0: # %entry
74 ; NO-VSX-NEXT: fneg 0, 2
75 ; NO-VSX-NEXT: fmadds 1, 0, 3, 1
78 %0 = fmul contract reassoc float %b, %c
79 %1 = fsub contract reassoc float %a, %0
83 define float @test_2mul_sub_f32(float %a, float %b, float %c, float %d) {
84 ; VSX-LABEL: test_2mul_sub_f32:
85 ; VSX: # %bb.0: # %entry
86 ; VSX-NEXT: xsmulsp 0, 3, 4
87 ; VSX-NEXT: xsmsubasp 0, 1, 2
91 ; NO-VSX-LABEL: test_2mul_sub_f32:
92 ; NO-VSX: # %bb.0: # %entry
93 ; NO-VSX-NEXT: fmuls 0, 3, 4
94 ; NO-VSX-NEXT: fmsubs 1, 1, 2, 0
97 %0 = fmul contract reassoc float %a, %b
98 %1 = fmul contract reassoc float %c, %d
99 %2 = fsub contract reassoc float %0, %1
103 define float @test_neg_fma_f32(float %a, float %b, float %c) {
104 ; VSX-LABEL: test_neg_fma_f32:
105 ; VSX: # %bb.0: # %entry
106 ; VSX-NEXT: xsnegdp 0, 1
107 ; VSX-NEXT: xsmaddasp 3, 0, 2
111 ; NO-VSX-LABEL: test_neg_fma_f32:
112 ; NO-VSX: # %bb.0: # %entry
113 ; NO-VSX-NEXT: fneg 0, 1
114 ; NO-VSX-NEXT: fmadds 1, 0, 2, 3
117 %0 = fsub contract reassoc float -0.0, %a
118 %1 = call contract reassoc float @llvm.fma.f32(float %0, float %b, float %c)
122 define <2 x double> @test_neg_fma_v2f64(<2 x double> %a, <2 x double> %b,
123 ; VSX-LABEL: test_neg_fma_v2f64:
124 ; VSX: # %bb.0: # %entry
125 ; VSX-NEXT: xvnegdp 0, 34
126 ; VSX-NEXT: xvmaddadp 36, 0, 35
130 ; NO-VSX-LABEL: test_neg_fma_v2f64:
131 ; NO-VSX: # %bb.0: # %entry
132 ; NO-VSX-NEXT: fneg 0, 2
133 ; NO-VSX-NEXT: fneg 1, 1
134 ; NO-VSX-NEXT: fmadd 1, 1, 3, 5
135 ; NO-VSX-NEXT: fmadd 2, 0, 4, 6
139 %0 = fsub contract reassoc <2 x double> <double -0.0, double -0.0>, %a
140 %1 = call contract reassoc <2 x double> @llvm.fma.v2f64(<2 x double> %0,
146 define <4 x float> @test_neg_fma_v4f32(<4 x float> %a, <4 x float> %b,
147 ; VSX-LABEL: test_neg_fma_v4f32:
148 ; VSX: # %bb.0: # %entry
149 ; VSX-NEXT: xvnegsp 0, 34
150 ; VSX-NEXT: xvmaddasp 36, 0, 35
154 ; NO-VSX-LABEL: test_neg_fma_v4f32:
155 ; NO-VSX: # %bb.0: # %entry
156 ; NO-VSX-NEXT: vspltisb 5, -1
157 ; NO-VSX-NEXT: vslw 5, 5, 5
158 ; NO-VSX-NEXT: vsubfp 2, 5, 2
159 ; NO-VSX-NEXT: vmaddfp 2, 2, 3, 4
163 %0 = fsub contract reassoc <4 x float> <float -0.0, float -0.0, float -0.0,
165 %1 = call contract reassoc <4 x float> @llvm.fma.v4f32(<4 x float> %0,
171 define double @test_fast_mul_sub_f64(double %a, double %b, double %c) {
172 ; VSX-LABEL: test_fast_mul_sub_f64:
173 ; VSX: # %bb.0: # %entry
174 ; VSX-NEXT: xsnmsubadp 1, 2, 3
177 ; NO-VSX-LABEL: test_fast_mul_sub_f64:
178 ; NO-VSX: # %bb.0: # %entry
179 ; NO-VSX-NEXT: fnmsub 1, 2, 3, 1
182 %0 = fmul contract reassoc nsz double %b, %c
183 %1 = fsub contract reassoc nsz double %a, %0
187 define double @test_fast_2mul_sub_f64(double %a, double %b, double %c,
188 ; VSX-LABEL: test_fast_2mul_sub_f64:
189 ; VSX: # %bb.0: # %entry
190 ; VSX-NEXT: xsmuldp 0, 3, 4
191 ; VSX-NEXT: xsmsubadp 0, 1, 2
195 ; NO-VSX-LABEL: test_fast_2mul_sub_f64:
196 ; NO-VSX: # %bb.0: # %entry
197 ; NO-VSX-NEXT: fmul 0, 3, 4
198 ; NO-VSX-NEXT: fmsub 1, 1, 2, 0
202 %0 = fmul contract reassoc double %a, %b
203 %1 = fmul contract reassoc double %c, %d
204 %2 = fsub contract reassoc double %0, %1
208 define double @test_fast_neg_fma_f64(double %a, double %b, double %c) {
209 ; VSX-LABEL: test_fast_neg_fma_f64:
210 ; VSX: # %bb.0: # %entry
211 ; VSX-NEXT: xsnmsubadp 3, 1, 2
215 ; NO-VSX-LABEL: test_fast_neg_fma_f64:
216 ; NO-VSX: # %bb.0: # %entry
217 ; NO-VSX-NEXT: fnmsub 1, 1, 2, 3
220 %0 = fsub reassoc double -0.0, %a
221 %1 = call reassoc nsz double @llvm.fma.f64(double %0, double %b, double %c)
225 define float @test_fast_mul_sub_f32(float %a, float %b, float %c) {
226 ; VSX-LABEL: test_fast_mul_sub_f32:
227 ; VSX: # %bb.0: # %entry
228 ; VSX-NEXT: xsnmsubasp 1, 2, 3
231 ; NO-VSX-LABEL: test_fast_mul_sub_f32:
232 ; NO-VSX: # %bb.0: # %entry
233 ; NO-VSX-NEXT: fnmsubs 1, 2, 3, 1
236 %0 = fmul contract reassoc float %b, %c
237 %1 = fsub contract reassoc nsz float %a, %0
241 define float @test_fast_2mul_sub_f32(float %a, float %b, float %c, float %d) {
242 ; VSX-LABEL: test_fast_2mul_sub_f32:
243 ; VSX: # %bb.0: # %entry
244 ; VSX-NEXT: xsmulsp 0, 3, 4
245 ; VSX-NEXT: xsmsubasp 0, 1, 2
249 ; NO-VSX-LABEL: test_fast_2mul_sub_f32:
250 ; NO-VSX: # %bb.0: # %entry
251 ; NO-VSX-NEXT: fmuls 0, 3, 4
252 ; NO-VSX-NEXT: fmsubs 1, 1, 2, 0
255 %0 = fmul contract reassoc float %a, %b
256 %1 = fmul contract reassoc float %c, %d
257 %2 = fsub contract reassoc nsz float %0, %1
261 define float @test_fast_neg_fma_f32(float %a, float %b, float %c) {
262 ; VSX-LABEL: test_fast_neg_fma_f32:
263 ; VSX: # %bb.0: # %entry
264 ; VSX-NEXT: xsnmsubasp 3, 1, 2
268 ; NO-VSX-LABEL: test_fast_neg_fma_f32:
269 ; NO-VSX: # %bb.0: # %entry
270 ; NO-VSX-NEXT: fnmsubs 1, 1, 2, 3
273 %0 = fsub reassoc float -0.0, %a
274 %1 = call reassoc nsz float @llvm.fma.f32(float %0, float %b, float %c)
278 define <2 x double> @test_fast_neg_fma_v2f64(<2 x double> %a, <2 x double> %b,
279 ; VSX-LABEL: test_fast_neg_fma_v2f64:
280 ; VSX: # %bb.0: # %entry
281 ; VSX-NEXT: xvnmsubadp 36, 34, 35
285 ; NO-VSX-LABEL: test_fast_neg_fma_v2f64:
286 ; NO-VSX: # %bb.0: # %entry
287 ; NO-VSX-NEXT: fnmsub 1, 1, 3, 5
288 ; NO-VSX-NEXT: fnmsub 2, 2, 4, 6
292 %0 = fsub reassoc <2 x double> <double -0.0, double -0.0>, %a
293 %1 = call reassoc nsz <2 x double> @llvm.fma.v2f64(<2 x double> %0, <2 x double> %b,
298 define <4 x float> @test_fast_neg_fma_v4f32(<4 x float> %a, <4 x float> %b,
299 ; VSX-LABEL: test_fast_neg_fma_v4f32:
300 ; VSX: # %bb.0: # %entry
301 ; VSX-NEXT: xvnmsubasp 36, 34, 35
305 ; NO-VSX-LABEL: test_fast_neg_fma_v4f32:
306 ; NO-VSX: # %bb.0: # %entry
307 ; NO-VSX-NEXT: vnmsubfp 2, 2, 3, 4
311 %0 = fsub reassoc <4 x float> <float -0.0, float -0.0, float -0.0,
313 %1 = call reassoc nsz <4 x float> @llvm.fma.v4f32(<4 x float> %0, <4 x float> %b,
318 declare float @llvm.fma.f32(float %a, float %b, float %c)
319 declare double @llvm.fma.f64(double %a, double %b, double %c)
320 declare <4 x float> @llvm.fma.v4f32(<4 x float> %a, <4 x float> %b,
322 declare <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> %b,