Fix typo.
[oota-llvm.git] / test / CodeGen / PowerPC / fma.ll
1 ; RUN: llc < %s -march=ppc32 -fp-contract=fast -mattr=-vsx | FileCheck %s
2 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -fp-contract=fast -mattr=+vsx -mcpu=pwr7 | FileCheck -check-prefix=CHECK-VSX %s
3 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -fp-contract=fast -mcpu=pwr8 | FileCheck -check-prefix=CHECK-P8 %s
4 ; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu -fp-contract=fast -mcpu=pwr8 | FileCheck -check-prefix=CHECK-P8 %s
5
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
10
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]
14         ret double %E
15 ; CHECK-LABEL: test_FMADD1:
16 ; CHECK: fmadd
17 ; CHECK-NEXT: blr
18
19 ; CHECK-VSX-LABEL: test_FMADD1:
20 ; CHECK-VSX: xsmaddmdp
21 ; CHECK-VSX-NEXT: blr
22 }
23
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]
27         ret double %E
28 ; CHECK-LABEL: test_FMADD2:
29 ; CHECK: fmadd
30 ; CHECK-NEXT: blr
31
32 ; CHECK-VSX-LABEL: test_FMADD2:
33 ; CHECK-VSX: xsmaddmdp
34 ; CHECK-VSX-NEXT: blr
35 }
36
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]
40         ret double %E
41 ; CHECK-LABEL: test_FMSUB1:
42 ; CHECK: fmsub
43 ; CHECK-NEXT: blr
44
45 ; CHECK-VSX-LABEL: test_FMSUB1:
46 ; CHECK-VSX: xsmsubmdp
47 ; CHECK-VSX-NEXT: blr
48 }
49
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]
55         ret double %H
56 ; CHECK-LABEL: test_FMSUB2:
57 ; CHECK: fmadd
58 ; CHECK-NEXT: fmsub
59
60 ; CHECK-VSX-LABEL: test_FMSUB2:
61 ; CHECK-VSX: xsmaddadp
62 ; CHECK-VSX-NEXT: xsmsubmdp
63 }
64
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]
69         ret double %F
70 ; CHECK-LABEL: test_FNMADD1:
71 ; CHECK: fnmadd
72 ; CHECK-NEXT: blr
73
74 ; CHECK-VSX-LABEL: test_FNMADD1:
75 ; CHECK-VSX: xsnmaddmdp
76 ; CHECK-VSX-NEXT: blr
77 }
78
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]
83         ret double %F
84 ; CHECK-LABEL: test_FNMADD2:
85 ; CHECK: fnmadd
86 ; CHECK-NEXT: blr
87
88 ; CHECK-VSX-LABEL: test_FNMADD2:
89 ; CHECK-VSX: xsnmaddmdp
90 ; CHECK-VSX-NEXT: blr
91 }
92
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]
96         ret double %E
97 ; CHECK-LABEL: test_FNMSUB1:
98 ; CHECK: fnmsub
99 ; CHECK-NEXT: blr
100
101 ; CHECK-VSX-LABEL: test_FNMSUB1:
102 ; CHECK-VSX: xsnmsubmdp
103 }
104
105 define double @test_FNMSUB2(double %A, double %B, double %C) {
106         %D = fmul double %A, %B         ; <double> [#uses=1]
107         %E = fsub double %D, %C         ; <double> [#uses=1]
108         %F = fsub double -0.000000e+00, %E              ; <double> [#uses=1]
109         ret double %F
110 ; CHECK-LABEL: test_FNMSUB2:
111 ; CHECK: fnmsub
112 ; CHECK-NEXT: blr
113
114 ; CHECK-VSX-LABEL: test_FNMSUB2:
115 ; CHECK-VSX: xsnmsubmdp
116 ; CHECK-VSX-NEXT: blr
117 }
118
119 define float @test_FNMSUBS(float %A, float %B, float %C) {
120         %D = fmul float %A, %B          ; <float> [#uses=1]
121         %E = fsub float %D, %C          ; <float> [#uses=1]
122         %F = fsub float -0.000000e+00, %E               ; <float> [#uses=1]
123         ret float %F
124 ; CHECK-LABEL: test_FNMSUBS:
125 ; CHECK: fnmsubs
126 ; CHECK-NEXT: blr
127
128 ; CHECK-VSX-LABEL: test_FNMSUBS:
129 ; CHECK-VSX: fnmsubs
130 ; CHECK-VSX-NEXT: blr
131 }
132
133 define float @test_XSMADDMSP(float %A, float %B, float %C) {
134         %D = fmul float %A, %B          ; <float> [#uses=1]
135         %E = fadd float %C, %D          ; <float> [#uses=1]
136         ret float %E
137 ; CHECK-P8-LABEL: test_XSMADDMSP:
138 ; CHECK-P8: xsmaddmsp
139 ; CHECK-P8-NEXT: blr
140 }
141
142 define float @test_XSMSUBMSP(float %A, float %B, float %C) {
143         %D = fmul float %A, %B          ; <float> [#uses=1]
144         %E = fsub float %D, %C          ; <float> [#uses=1]
145         ret float %E
146 ; CHECK-P8-LABEL: test_XSMSUBMSP:
147 ; CHECK-P8: xsmsubmsp
148 ; CHECK-P8-NEXT: blr
149 }
150
151 define float @test_XSMADDASP(float %A, float %B, float %C, float %D) {
152         %E = fmul float %A, %B  ; <float> [#uses=2]
153         %F = fadd float %E, %C  ; <float> [#uses=1]
154         %G = fsub float %E, %D  ; <float> [#uses=1]
155         %H = call float @dummy4(float %F, float %G)      ; <float> [#uses=1]
156         ret float %H
157 ; CHECK-P8-LABEL: test_XSMADDASP:
158 ; CHECK-P8: xsmaddasp
159 ; CHECK-P8-NEXT: xsmsubmsp
160 }
161
162 define float @test_XSMSUBASP(float %A, float %B, float %C, float %D) {
163         %E = fmul float %A, %B  ; <float> [#uses=2]
164         %F = fsub float %E, %C  ; <float> [#uses=1]
165         %G = fsub float %E, %D  ; <float> [#uses=1]
166         %H = call float @dummy4(float %F, float %G)      ; <float> [#uses=1]
167         ret float %H
168 ; CHECK-P8-LABEL: test_XSMSUBASP:
169 ; CHECK-P8: xsmsubasp
170 ; CHECK-P8-NEXT: xsmsubmsp
171 }
172
173 define float @test_XSNMADDMSP(float %A, float %B, float %C) {
174         %D = fmul float %A, %B          ; <float> [#uses=1]
175         %E = fadd float %D, %C          ; <float> [#uses=1]
176         %F = fsub float -0.000000e+00, %E               ; <float> [#uses=1]
177         ret float %F
178 ; CHECK-P8-LABEL: test_XSNMADDMSP:
179 ; CHECK-P8: xsnmaddmsp
180 ; CHECK-P8-NEXT: blr
181 }
182
183 define float @test_XSNMSUBMSP(float %A, float %B, float %C) {
184         %D = fmul float %A, %B          ; <float> [#uses=1]
185         %E = fsub float %D, %C          ; <float> [#uses=1]
186         %F = fsub float -0.000000e+00, %E               ; <float> [#uses=1]
187         ret float %F
188 ; CHECK-P8-LABEL: test_XSNMSUBMSP:
189 ; CHECK-P8: xsnmsubmsp
190 ; CHECK-P8-NEXT: blr
191 }
192
193 define float @test_XSNMADDASP(float %A, float %B, float %C) {
194         %D = fmul float %A, %B          ; <float> [#uses=1]
195         %E = fadd float %D, %C          ; <float> [#uses=1]
196         %F = fsub float -0.000000e+00, %E               ; <float> [#uses=1]
197         %H = call float @dummy4(float %E, float %F)      ; <float> [#uses=1]
198         ret float %F
199 ; CHECK-P8-LABEL: test_XSNMADDASP:
200 ; CHECK-P8: xsnmaddasp
201 }
202
203 define float @test_XSNMSUBASP(float %A, float %B, float %C) {
204         %D = fmul float %A, %B          ; <float> [#uses=1]
205         %E = fsub float %D, %C          ; <float> [#uses=1]
206         %F = fsub float -0.000000e+00, %E               ; <float> [#uses=1]
207         %H = call float @dummy4(float %E, float %F)      ; <float> [#uses=1]
208         ret float %F
209 ; CHECK-P8-LABEL: test_XSNMSUBASP:
210 ; CHECK-P8: xsnmsubasp
211 }