1 ; RUN: llc -verify-machineinstrs < %s -mtriple=ppc32-- -fp-contract=fast -mattr=-vsx -disable-ppc-vsx-fma-mutation=false | FileCheck %s
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -fp-contract=fast -mattr=+vsx -mcpu=pwr7 -disable-ppc-vsx-fma-mutation=false | FileCheck -check-prefix=CHECK-VSX %s
3 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu -fp-contract=fast -mcpu=pwr8 -disable-ppc-vsx-fma-mutation=false | FileCheck -check-prefix=CHECK-P8 %s
4 ; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-linux-gnu -fp-contract=fast -mcpu=pwr8 -disable-ppc-vsx-fma-mutation=false | FileCheck -check-prefix=CHECK-P8 %s
6 declare double @dummy1(double) #0
7 declare double @dummy2(double, double) #0
8 declare double @dummy3(double, double, double) #0
9 declare float @dummy4(float, float) #0
11 define double @test_FMADD1(double %A, double %B, double %C) {
12 %D = fmul double %A, %B ; <double> [#uses=1]
13 %E = fadd double %C, %D ; <double> [#uses=1]
15 ; CHECK-LABEL: test_FMADD1:
19 ; CHECK-VSX-LABEL: test_FMADD1:
20 ; CHECK-VSX: xsmaddmdp
24 define double @test_FMADD2(double %A, double %B, double %C) {
25 %D = fmul double %A, %B ; <double> [#uses=1]
26 %E = fadd double %D, %C ; <double> [#uses=1]
28 ; CHECK-LABEL: test_FMADD2:
32 ; CHECK-VSX-LABEL: test_FMADD2:
33 ; CHECK-VSX: xsmaddmdp
37 define double @test_FMSUB1(double %A, double %B, double %C) {
38 %D = fmul double %A, %B ; <double> [#uses=1]
39 %E = fsub double %D, %C ; <double> [#uses=1]
41 ; CHECK-LABEL: test_FMSUB1:
45 ; CHECK-VSX-LABEL: test_FMSUB1:
46 ; CHECK-VSX: xsmsubmdp
50 define double @test_FMSUB2(double %A, double %B, double %C, double %D) {
51 %E = fmul double %A, %B ; <double> [#uses=2]
52 %F = fadd double %E, %C ; <double> [#uses=1]
53 %G = fsub double %E, %D ; <double> [#uses=1]
54 %H = call double @dummy2(double %F, double %G) ; <double> [#uses=1]
56 ; CHECK-LABEL: test_FMSUB2:
60 ; CHECK-VSX-LABEL: test_FMSUB2:
61 ; CHECK-VSX: xsmaddadp
62 ; CHECK-VSX-NEXT: xsmsubmdp
65 define double @test_FNMADD1(double %A, double %B, double %C) {
66 %D = fmul double %A, %B ; <double> [#uses=1]
67 %E = fadd double %D, %C ; <double> [#uses=1]
68 %F = fsub double -0.000000e+00, %E ; <double> [#uses=1]
70 ; CHECK-LABEL: test_FNMADD1:
74 ; CHECK-VSX-LABEL: test_FNMADD1:
75 ; CHECK-VSX: xsnmaddmdp
79 define double @test_FNMADD2(double %A, double %B, double %C) {
80 %D = fmul double %A, %B ; <double> [#uses=1]
81 %E = fadd double %C, %D ; <double> [#uses=1]
82 %F = fsub double -0.000000e+00, %E ; <double> [#uses=1]
84 ; CHECK-LABEL: test_FNMADD2:
88 ; CHECK-VSX-LABEL: test_FNMADD2:
89 ; CHECK-VSX: xsnmaddmdp
93 define double @test_FNMSUB1(double %A, double %B, double %C) {
94 %D = fmul double %A, %B ; <double> [#uses=1]
95 %E = fsub double %C, %D ; <double> [#uses=1]
97 ; CHECK-LABEL: test_FNMSUB1:
102 ; CHECK-VSX-LABEL: test_FNMSUB1:
104 ; CHECK-VSX-NEXT: xsmaddmdp
107 ; need nsz flag to generate fnmsub since it may affect sign of zero
108 define double @test_FNMSUB1_NSZ(double %A, double %B, double %C) {
109 %D = fmul nsz double %A, %B ; <double> [#uses=1]
110 %E = fsub nsz double %C, %D ; <double> [#uses=1]
112 ; CHECK-LABEL: test_FNMSUB1_NSZ:
116 ; CHECK-VSX-LABEL: test_FNMSUB1_NSZ:
117 ; CHECK-VSX: xsnmsubmdp
120 define double @test_FNMSUB2(double %A, double %B, double %C) {
121 %D = fmul double %A, %B ; <double> [#uses=1]
122 %E = fsub double %D, %C ; <double> [#uses=1]
123 %F = fsub double -0.000000e+00, %E ; <double> [#uses=1]
125 ; CHECK-LABEL: test_FNMSUB2:
129 ; CHECK-VSX-LABEL: test_FNMSUB2:
130 ; CHECK-VSX: xsnmsubmdp
131 ; CHECK-VSX-NEXT: blr
134 define float @test_FNMSUBS(float %A, float %B, float %C) {
135 %D = fmul float %A, %B ; <float> [#uses=1]
136 %E = fsub float %D, %C ; <float> [#uses=1]
137 %F = fsub float -0.000000e+00, %E ; <float> [#uses=1]
139 ; CHECK-LABEL: test_FNMSUBS:
143 ; CHECK-VSX-LABEL: test_FNMSUBS:
145 ; CHECK-VSX-NEXT: blr
148 define float @test_XSMADDMSP(float %A, float %B, float %C) {
149 %D = fmul float %A, %B ; <float> [#uses=1]
150 %E = fadd float %C, %D ; <float> [#uses=1]
152 ; CHECK-P8-LABEL: test_XSMADDMSP:
153 ; CHECK-P8: xsmaddmsp
157 define float @test_XSMSUBMSP(float %A, float %B, float %C) {
158 %D = fmul float %A, %B ; <float> [#uses=1]
159 %E = fsub float %D, %C ; <float> [#uses=1]
161 ; CHECK-P8-LABEL: test_XSMSUBMSP:
162 ; CHECK-P8: xsmsubmsp
166 define float @test_XSMADDASP(float %A, float %B, float %C, float %D) {
167 %E = fmul float %A, %B ; <float> [#uses=2]
168 %F = fadd float %E, %C ; <float> [#uses=1]
169 %G = fsub float %E, %D ; <float> [#uses=1]
170 %H = call float @dummy4(float %F, float %G) ; <float> [#uses=1]
172 ; CHECK-P8-LABEL: test_XSMADDASP:
173 ; CHECK-P8: xsmaddasp
174 ; CHECK-P8-NEXT: xsmsubmsp
177 define float @test_XSMSUBASP(float %A, float %B, float %C, float %D) {
178 %E = fmul float %A, %B ; <float> [#uses=2]
179 %F = fsub float %E, %C ; <float> [#uses=1]
180 %G = fsub float %E, %D ; <float> [#uses=1]
181 %H = call float @dummy4(float %F, float %G) ; <float> [#uses=1]
183 ; CHECK-P8-LABEL: test_XSMSUBASP:
184 ; CHECK-P8: xsmsubasp
185 ; CHECK-P8-NEXT: xsmsubmsp
188 define float @test_XSNMADDMSP(float %A, float %B, float %C) {
189 %D = fmul float %A, %B ; <float> [#uses=1]
190 %E = fadd float %D, %C ; <float> [#uses=1]
191 %F = fsub float -0.000000e+00, %E ; <float> [#uses=1]
193 ; CHECK-P8-LABEL: test_XSNMADDMSP:
194 ; CHECK-P8: xsnmaddmsp
198 define float @test_XSNMSUBMSP(float %A, float %B, float %C) {
199 %D = fmul float %A, %B ; <float> [#uses=1]
200 %E = fsub float %D, %C ; <float> [#uses=1]
201 %F = fsub float -0.000000e+00, %E ; <float> [#uses=1]
203 ; CHECK-P8-LABEL: test_XSNMSUBMSP:
204 ; CHECK-P8: xsnmsubmsp
208 define float @test_XSNMADDASP(float %A, float %B, float %C) {
209 %D = fmul float %A, %B ; <float> [#uses=1]
210 %E = fadd float %D, %C ; <float> [#uses=1]
211 %F = fsub float -0.000000e+00, %E ; <float> [#uses=1]
212 %H = call float @dummy4(float %E, float %F) ; <float> [#uses=1]
214 ; CHECK-P8-LABEL: test_XSNMADDASP:
215 ; CHECK-P8: xsnmaddasp
217 ; CHECK-VSX-LABEL: test_XSNMADDASP:
221 define float @test_XSNMSUBASP(float %A, float %B, float %C) {
222 %D = fmul float %A, %B ; <float> [#uses=1]
223 %E = fsub float %D, %C ; <float> [#uses=1]
224 %F = fsub float -0.000000e+00, %E ; <float> [#uses=1]
225 %H = call float @dummy4(float %E, float %F) ; <float> [#uses=1]
227 ; CHECK-P8-LABEL: test_XSNMSUBASP:
228 ; CHECK-P8: xsnmsubasp
230 ; CHECK-VSX-LABEL: test_XSNMSUBASP: