1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
4 define float @fadd_zero_f32(float %x) #0 {
5 ; CHECK-LABEL: fadd_zero_f32:
8 %y = fadd float %x, 0.0
12 define <4 x float> @fadd_zero_4f32(<4 x float> %x) #0 {
13 ; CHECK-LABEL: fadd_zero_4f32:
16 %y = fadd <4 x float> %x, zeroinitializer
20 define <4 x float> @fadd_zero_4f32_undef(<4 x float> %x) {
21 ; CHECK-LABEL: fadd_zero_4f32_undef:
24 %y = fadd nsz <4 x float> %x, <float 0.0, float undef, float 0.0, float undef>
29 define float @fadd_2const_f32(float %x) #0 {
30 ; CHECK-LABEL: fadd_2const_f32:
32 ; CHECK-NEXT: addss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
34 %y = fadd float %x, 1.0
35 %z = fadd float %y, 2.0
43 define <4 x float> @fadd_2const_4f32(<4 x float> %x) #0 {
44 ; CHECK-LABEL: fadd_2const_4f32:
46 ; CHECK-NEXT: addps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
48 %y = fadd <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
49 %z = fadd <4 x float> %y, <float 4.0, float 3.0, float 2.0, float 1.0>
54 define float @fadd_x_fmul_x_c_f32(float %x) #0 {
55 ; CHECK-LABEL: fadd_x_fmul_x_c_f32:
57 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
59 %y = fmul float %x, 2.0
60 %z = fadd float %x, %y
68 define <4 x float> @fadd_x_fmul_x_c_4f32(<4 x float> %x) #0 {
69 ; CHECK-LABEL: fadd_x_fmul_x_c_4f32:
71 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
73 %y = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
74 %z = fadd <4 x float> %x, %y
79 define float @fadd_fmul_x_c_x_f32(float %x) #0 {
80 ; CHECK-LABEL: fadd_fmul_x_c_x_f32:
82 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
84 %y = fmul float %x, 2.0
85 %z = fadd float %y, %x
93 define <4 x float> @fadd_fmul_x_c_x_4f32(<4 x float> %x) #0 {
94 ; CHECK-LABEL: fadd_fmul_x_c_x_4f32:
96 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
98 %y = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
99 %z = fadd <4 x float> %y, %x
104 define float @fadd_fadd_x_x_fmul_x_c_f32(float %x) #0 {
105 ; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_f32:
107 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
109 %y = fadd float %x, %x
110 %z = fmul float %x, 2.0
111 %w = fadd float %y, %z
119 define <4 x float> @fadd_fadd_x_x_fmul_x_c_4f32(<4 x float> %x) #0 {
120 ; CHECK-LABEL: fadd_fadd_x_x_fmul_x_c_4f32:
122 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
124 %y = fadd <4 x float> %x, %x
125 %z = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
126 %w = fadd <4 x float> %y, %z
131 define float @fadd_fmul_x_c_fadd_x_x_f32(float %x) #0 {
132 ; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_f32:
134 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
136 %y = fadd float %x, %x
137 %z = fmul float %x, 2.0
138 %w = fadd float %z, %y
146 define <4 x float> @fadd_fmul_x_c_fadd_x_x_4f32(<4 x float> %x) #0 {
147 ; CHECK-LABEL: fadd_fmul_x_c_fadd_x_x_4f32:
149 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
151 %y = fadd <4 x float> %x, %x
152 %z = fmul <4 x float> %x, <float 1.0, float 2.0, float 3.0, float 4.0>
153 %w = fadd <4 x float> %z, %y
158 define float @fadd_x_fadd_x_x_f32(float %x) #0 {
159 ; CHECK-LABEL: fadd_x_fadd_x_x_f32:
161 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
163 %y = fadd float %x, %x
164 %z = fadd float %x, %y
172 define <4 x float> @fadd_x_fadd_x_x_4f32(<4 x float> %x) #0 {
173 ; CHECK-LABEL: fadd_x_fadd_x_x_4f32:
175 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
177 %y = fadd <4 x float> %x, %x
178 %z = fadd <4 x float> %x, %y
183 define float @fadd_fadd_x_x_x_f32(float %x) #0 {
184 ; CHECK-LABEL: fadd_fadd_x_x_x_f32:
186 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
188 %y = fadd float %x, %x
189 %z = fadd float %y, %x
197 define <4 x float> @fadd_fadd_x_x_x_4f32(<4 x float> %x) #0 {
198 ; CHECK-LABEL: fadd_fadd_x_x_x_4f32:
200 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
202 %y = fadd <4 x float> %x, %x
203 %z = fadd <4 x float> %y, %x
208 define float @fadd_fadd_x_x_fadd_x_x_f32(float %x) #0 {
209 ; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_f32:
211 ; CHECK-NEXT: mulss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
213 %y = fadd float %x, %x
214 %z = fadd float %y, %y
222 define <4 x float> @fadd_fadd_x_x_fadd_x_x_4f32(<4 x float> %x) #0 {
223 ; CHECK-LABEL: fadd_fadd_x_x_fadd_x_x_4f32:
225 ; CHECK-NEXT: mulps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
227 %y = fadd <4 x float> %x, %x
228 %z = fadd <4 x float> %y, %y
232 ; ((x + 42.0) + 17.0) + (x + 42.0) --> (x + 59.0) + (x + 17.0)
233 ; It's still 3 adds, but the first 2 are independent.
234 ; More reassocation could get this to 2 adds or 1 FMA (that's done in IR, but not in the DAG).
236 define float @fadd_const_multiuse_attr(float %x) #0 {
237 ; CHECK-LABEL: fadd_const_multiuse_attr:
239 ; CHECK-NEXT: movss {{.*#+}} xmm1 = [4.2E+1,0.0E+0,0.0E+0,0.0E+0]
240 ; CHECK-NEXT: addss %xmm0, %xmm1
241 ; CHECK-NEXT: addss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
242 ; CHECK-NEXT: addss %xmm1, %xmm0
244 %a1 = fadd float %x, 42.0
245 %a2 = fadd float %a1, 17.0
246 %a3 = fadd float %a1, %a2
250 ; PR32939 - https://bugs.llvm.org/show_bug.cgi?id=32939
252 define double @fmul2_negated(double %a, double %b, double %c) {
253 ; CHECK-LABEL: fmul2_negated:
255 ; CHECK-NEXT: addsd %xmm1, %xmm1
256 ; CHECK-NEXT: mulsd %xmm2, %xmm1
257 ; CHECK-NEXT: subsd %xmm1, %xmm0
259 %mul = fmul double %b, 2.0
260 %mul1 = fmul double %mul, %c
261 %sub = fsub double %a, %mul1
265 define <2 x double> @fmul2_negated_vec(<2 x double> %a, <2 x double> %b, <2 x double> %c) {
266 ; CHECK-LABEL: fmul2_negated_vec:
268 ; CHECK-NEXT: addpd %xmm1, %xmm1
269 ; CHECK-NEXT: mulpd %xmm2, %xmm1
270 ; CHECK-NEXT: subpd %xmm1, %xmm0
272 %mul = fmul <2 x double> %b, <double 2.0, double 2.0>
273 %mul1 = fmul <2 x double> %mul, %c
274 %sub = fsub <2 x double> %a, %mul1
275 ret <2 x double> %sub
278 attributes #0 = { "less-precise-fpmad"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" "no-signed-zeros-fp-math"="true" }