1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 declare float @llvm.fma.f32(float, float, float) #1
5 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>) #1
6 declare <8 x half> @llvm.fma.v8f16(<8 x half>, <8 x half>, <8 x half>) #1
7 declare float @llvm.fmuladd.f32(float, float, float) #1
8 declare float @llvm.fabs.f32(float) #1
10 @external = external global i32
12 define float @fma_fneg_x_fneg_y(float %x, float %y, float %z) {
13 ; CHECK-LABEL: @fma_fneg_x_fneg_y(
14 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
15 ; CHECK-NEXT: ret float [[FMA]]
17 %x.fneg = fsub float -0.0, %x
18 %y.fneg = fsub float -0.0, %y
19 %fma = call float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
23 define float @fma_unary_fneg_x_unary_fneg_y(float %x, float %y, float %z) {
24 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y(
25 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
26 ; CHECK-NEXT: ret float [[FMA]]
28 %x.fneg = fneg float %x
29 %y.fneg = fneg float %y
30 %fma = call float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
34 define <2 x float> @fma_fneg_x_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
35 ; CHECK-LABEL: @fma_fneg_x_fneg_y_vec(
36 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
37 ; CHECK-NEXT: ret <2 x float> [[FMA]]
39 %xn = fsub <2 x float> <float -0.0, float -0.0>, %x
40 %yn = fsub <2 x float> <float -0.0, float -0.0>, %y
41 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z)
45 define <2 x float> @fma_unary_fneg_x_unary_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
46 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y_vec(
47 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
48 ; CHECK-NEXT: ret <2 x float> [[FMA]]
50 %xn = fneg <2 x float> %x
51 %yn = fneg <2 x float> %y
52 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z)
56 define <2 x float> @fma_fneg_x_fneg_y_vec_undef(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
57 ; CHECK-LABEL: @fma_fneg_x_fneg_y_vec_undef(
58 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
59 ; CHECK-NEXT: ret <2 x float> [[FMA]]
61 %xn = fsub <2 x float> <float -0.0, float undef>, %x
62 %yn = fsub <2 x float> <float undef, float -0.0>, %y
63 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z)
67 define float @fma_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
68 ; CHECK-LABEL: @fma_fneg_x_fneg_y_fast(
69 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
70 ; CHECK-NEXT: ret float [[FMA]]
72 %x.fneg = fsub float -0.0, %x
73 %y.fneg = fsub float -0.0, %y
74 %fma = call fast float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
78 define float @fma_unary_fneg_x_unary_fneg_y_fast(float %x, float %y, float %z) {
79 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y_fast(
80 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
81 ; CHECK-NEXT: ret float [[FMA]]
83 %x.fneg = fneg float %x
84 %y.fneg = fneg float %y
85 %fma = call fast float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
89 define float @fma_fneg_const_fneg_y(float %y, float %z) {
90 ; CHECK-LABEL: @fma_fneg_const_fneg_y(
91 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
92 ; CHECK-NEXT: ret float [[FMA]]
94 %y.fneg = fsub float -0.0, %y
95 %fma = call float @llvm.fma.f32(float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
99 define float @fma_unary_fneg_const_unary_fneg_y(float %y, float %z) {
100 ; CHECK-LABEL: @fma_unary_fneg_const_unary_fneg_y(
101 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
102 ; CHECK-NEXT: ret float [[FMA]]
104 %y.fneg = fneg float %y
105 %fma = call float @llvm.fma.f32(float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
109 define float @fma_fneg_x_fneg_const(float %x, float %z) {
110 ; CHECK-LABEL: @fma_fneg_x_fneg_const(
111 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
112 ; CHECK-NEXT: ret float [[FMA]]
114 %x.fneg = fsub float -0.0, %x
115 %fma = call float @llvm.fma.f32(float %x.fneg, float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
119 define float @fma_unary_fneg_x_unary_fneg_const(float %x, float %z) {
120 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_const(
121 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
122 ; CHECK-NEXT: ret float [[FMA]]
124 %x.fneg = fneg float %x
125 %fma = call float @llvm.fma.f32(float %x.fneg, float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
129 define float @fma_fabs_x_fabs_y(float %x, float %y, float %z) {
130 ; CHECK-LABEL: @fma_fabs_x_fabs_y(
131 ; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
132 ; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
133 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X_FABS]], float [[Y_FABS]], float [[Z:%.*]])
134 ; CHECK-NEXT: ret float [[FMA]]
136 %x.fabs = call float @llvm.fabs.f32(float %x)
137 %y.fabs = call float @llvm.fabs.f32(float %y)
138 %fma = call float @llvm.fma.f32(float %x.fabs, float %y.fabs, float %z)
142 define float @fma_fabs_x_fabs_x(float %x, float %z) {
143 ; CHECK-LABEL: @fma_fabs_x_fabs_x(
144 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
145 ; CHECK-NEXT: ret float [[FMA]]
147 %x.fabs = call float @llvm.fabs.f32(float %x)
148 %fma = call float @llvm.fma.f32(float %x.fabs, float %x.fabs, float %z)
152 define float @fma_fabs_x_fabs_x_fast(float %x, float %z) {
153 ; CHECK-LABEL: @fma_fabs_x_fabs_x_fast(
154 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
155 ; CHECK-NEXT: ret float [[FMA]]
157 %x.fabs = call float @llvm.fabs.f32(float %x)
158 %fma = call fast float @llvm.fma.f32(float %x.fabs, float %x.fabs, float %z)
162 define float @fmuladd_fneg_x_fneg_y(float %x, float %y, float %z) {
163 ; CHECK-LABEL: @fmuladd_fneg_x_fneg_y(
164 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
165 ; CHECK-NEXT: ret float [[FMULADD]]
167 %x.fneg = fsub float -0.0, %x
168 %y.fneg = fsub float -0.0, %y
169 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
173 define float @fmuladd_unary_fneg_x_unary_fneg_y(float %x, float %y, float %z) {
174 ; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_y(
175 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
176 ; CHECK-NEXT: ret float [[FMULADD]]
178 %x.fneg = fneg float %x
179 %y.fneg = fneg float %y
180 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
184 define float @fmuladd_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
185 ; CHECK-LABEL: @fmuladd_fneg_x_fneg_y_fast(
186 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[Y:%.*]]
187 ; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
188 ; CHECK-NEXT: ret float [[FMULADD]]
190 %x.fneg = fsub float -0.0, %x
191 %y.fneg = fsub float -0.0, %y
192 %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
196 define float @fmuladd_unary_fneg_x_unary_fneg_y_fast(float %x, float %y, float %z) {
197 ; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_y_fast(
198 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[Y:%.*]]
199 ; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
200 ; CHECK-NEXT: ret float [[FMULADD]]
202 %x.fneg = fneg float %x
203 %y.fneg = fneg float %y
204 %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
208 define float @fmuladd_fneg_const_fneg_y(float %y, float %z) {
209 ; CHECK-LABEL: @fmuladd_fneg_const_fneg_y(
210 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
211 ; CHECK-NEXT: ret float [[FMULADD]]
213 %y.fneg = fsub float -0.0, %y
214 %fmuladd = call float @llvm.fmuladd.f32(float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
218 define float @fmuladd_unary_fneg_const_unary_fneg_y(float %y, float %z) {
219 ; CHECK-LABEL: @fmuladd_unary_fneg_const_unary_fneg_y(
220 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
221 ; CHECK-NEXT: ret float [[FMULADD]]
223 %y.fneg = fneg float %y
224 %fmuladd = call float @llvm.fmuladd.f32(float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %y.fneg, float %z)
228 define float @fmuladd_fneg_x_fneg_const(float %x, float %z) {
229 ; CHECK-LABEL: @fmuladd_fneg_x_fneg_const(
230 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
231 ; CHECK-NEXT: ret float [[FMULADD]]
233 %x.fneg = fsub float -0.0, %x
234 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float fsub (float -0.0, float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
238 define float @fmuladd_unary_fneg_x_unary_fneg_const(float %x, float %z) {
239 ; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_const(
240 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (i32* @external to i32) to float), float [[Z:%.*]])
241 ; CHECK-NEXT: ret float [[FMULADD]]
243 %x.fneg = fneg float %x
244 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float fneg (float bitcast (i32 ptrtoint (i32* @external to i32) to float)), float %z)
248 define float @fmuladd_fabs_x_fabs_y(float %x, float %y, float %z) {
249 ; CHECK-LABEL: @fmuladd_fabs_x_fabs_y(
250 ; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
251 ; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
252 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X_FABS]], float [[Y_FABS]], float [[Z:%.*]])
253 ; CHECK-NEXT: ret float [[FMULADD]]
255 %x.fabs = call float @llvm.fabs.f32(float %x)
256 %y.fabs = call float @llvm.fabs.f32(float %y)
257 %fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %y.fabs, float %z)
261 define float @fmuladd_fabs_x_fabs_x(float %x, float %z) {
262 ; CHECK-LABEL: @fmuladd_fabs_x_fabs_x(
263 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
264 ; CHECK-NEXT: ret float [[FMULADD]]
266 %x.fabs = call float @llvm.fabs.f32(float %x)
267 %fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
271 define float @fmuladd_fabs_x_fabs_x_fast(float %x, float %z) {
272 ; CHECK-LABEL: @fmuladd_fabs_x_fabs_x_fast(
273 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[X]]
274 ; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
275 ; CHECK-NEXT: ret float [[FMULADD]]
277 %x.fabs = call float @llvm.fabs.f32(float %x)
278 %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
282 define float @fma_k_y_z(float %y, float %z) {
283 ; CHECK-LABEL: @fma_k_y_z(
284 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
285 ; CHECK-NEXT: ret float [[FMA]]
287 %fma = call float @llvm.fma.f32(float 4.0, float %y, float %z)
291 define float @fma_k_y_z_fast(float %y, float %z) {
292 ; CHECK-LABEL: @fma_k_y_z_fast(
293 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
294 ; CHECK-NEXT: ret float [[FMA]]
296 %fma = call fast float @llvm.fma.f32(float 4.0, float %y, float %z)
300 define float @fmuladd_k_y_z_fast(float %y, float %z) {
301 ; CHECK-LABEL: @fmuladd_k_y_z_fast(
302 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[Y:%.*]], 4.000000e+00
303 ; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[TMP1]], [[Z:%.*]]
304 ; CHECK-NEXT: ret float [[FMULADD]]
306 %fmuladd = call fast float @llvm.fmuladd.f32(float 4.0, float %y, float %z)
310 define float @fma_1_y_z(float %y, float %z) {
311 ; CHECK-LABEL: @fma_1_y_z(
312 ; CHECK-NEXT: [[FMA:%.*]] = fadd float [[Y:%.*]], [[Z:%.*]]
313 ; CHECK-NEXT: ret float [[FMA]]
315 %fma = call float @llvm.fma.f32(float 1.0, float %y, float %z)
319 define float @fma_x_1_z(float %x, float %z) {
320 ; CHECK-LABEL: @fma_x_1_z(
321 ; CHECK-NEXT: [[FMA:%.*]] = fadd float [[X:%.*]], [[Z:%.*]]
322 ; CHECK-NEXT: ret float [[FMA]]
324 %fma = call float @llvm.fma.f32(float %x, float 1.0, float %z)
328 define <2 x float> @fma_x_1_z_v2f32(<2 x float> %x, <2 x float> %z) {
329 ; CHECK-LABEL: @fma_x_1_z_v2f32(
330 ; CHECK-NEXT: [[FMA:%.*]] = fadd <2 x float> [[X:%.*]], [[Z:%.*]]
331 ; CHECK-NEXT: ret <2 x float> [[FMA]]
333 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %x, <2 x float> <float 1.0, float 1.0>, <2 x float> %z)
337 define <2 x float> @fma_x_1_2_z_v2f32(<2 x float> %x, <2 x float> %z) {
338 ; CHECK-LABEL: @fma_x_1_2_z_v2f32(
339 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> <float 1.000000e+00, float 2.000000e+00>, <2 x float> [[Z:%.*]])
340 ; CHECK-NEXT: ret <2 x float> [[FMA]]
342 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %x, <2 x float> <float 1.0, float 2.0>, <2 x float> %z)
346 define float @fma_x_1_z_fast(float %x, float %z) {
347 ; CHECK-LABEL: @fma_x_1_z_fast(
348 ; CHECK-NEXT: [[FMA:%.*]] = fadd fast float [[X:%.*]], [[Z:%.*]]
349 ; CHECK-NEXT: ret float [[FMA]]
351 %fma = call fast float @llvm.fma.f32(float %x, float 1.0, float %z)
355 define float @fma_1_1_z(float %z) {
356 ; CHECK-LABEL: @fma_1_1_z(
357 ; CHECK-NEXT: [[FMA:%.*]] = fadd float [[Z:%.*]], 1.000000e+00
358 ; CHECK-NEXT: ret float [[FMA]]
360 %fma = call float @llvm.fma.f32(float 1.0, float 1.0, float %z)
364 define float @fma_x_y_0(float %x, float %y) {
365 ; CHECK-LABEL: @fma_x_y_0(
366 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float 0.000000e+00)
367 ; CHECK-NEXT: ret float [[FMA]]
369 %fma = call float @llvm.fma.f32(float %x, float %y, float 0.0)
373 define float @fma_x_y_0_nsz(float %x, float %y) {
374 ; CHECK-LABEL: @fma_x_y_0_nsz(
375 ; CHECK-NEXT: [[FMA:%.*]] = fmul nsz float [[X:%.*]], [[Y:%.*]]
376 ; CHECK-NEXT: ret float [[FMA]]
378 %fma = call nsz float @llvm.fma.f32(float %x, float %y, float 0.0)
382 define <8 x half> @fma_x_y_0_v(<8 x half> %x, <8 x half> %y) {
383 ; CHECK-LABEL: @fma_x_y_0_v(
384 ; CHECK-NEXT: [[FMA:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> [[X:%.*]], <8 x half> [[Y:%.*]], <8 x half> zeroinitializer)
385 ; CHECK-NEXT: ret <8 x half> [[FMA]]
387 %fma = call <8 x half> @llvm.fma.v8f16(<8 x half> %x, <8 x half> %y, <8 x half> zeroinitializer)
391 define <8 x half> @fma_x_y_0_nsz_v(<8 x half> %x, <8 x half> %y) {
392 ; CHECK-LABEL: @fma_x_y_0_nsz_v(
393 ; CHECK-NEXT: [[FMA:%.*]] = fmul nsz <8 x half> [[X:%.*]], [[Y:%.*]]
394 ; CHECK-NEXT: ret <8 x half> [[FMA]]
396 %fma = call nsz <8 x half> @llvm.fma.v8f16(<8 x half> %x, <8 x half> %y, <8 x half> zeroinitializer)
400 define float @fmuladd_x_y_0(float %x, float %y) {
401 ; CHECK-LABEL: @fmuladd_x_y_0(
402 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float 0.000000e+00)
403 ; CHECK-NEXT: ret float [[FMA]]
405 %fma = call float @llvm.fmuladd.f32(float %x, float %y, float 0.0)
409 define float @fmuladd_x_y_0_nsz(float %x, float %y) {
410 ; CHECK-LABEL: @fmuladd_x_y_0_nsz(
411 ; CHECK-NEXT: [[FMA:%.*]] = fmul nsz float [[X:%.*]], [[Y:%.*]]
412 ; CHECK-NEXT: ret float [[FMA]]
414 %fma = call nsz float @llvm.fmuladd.f32(float %x, float %y, float 0.0)
418 define float @fma_x_y_m0(float %x, float %y) {
419 ; CHECK-LABEL: @fma_x_y_m0(
420 ; CHECK-NEXT: [[FMA:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
421 ; CHECK-NEXT: ret float [[FMA]]
423 %fma = call float @llvm.fma.f32(float %x, float %y, float -0.0)
427 define <8 x half> @fma_x_y_m0_v(<8 x half> %x, <8 x half> %y) {
428 ; CHECK-LABEL: @fma_x_y_m0_v(
429 ; CHECK-NEXT: [[FMA:%.*]] = fmul <8 x half> [[X:%.*]], [[Y:%.*]]
430 ; CHECK-NEXT: ret <8 x half> [[FMA]]
432 %fma = call <8 x half> @llvm.fma.v8f16(<8 x half> %x, <8 x half> %y, <8 x half> <half -0.0, half -0.0, half -0.0, half -0.0, half -0.0, half -0.0, half -0.0, half -0.0>)
436 define float @fmuladd_x_y_m0(float %x, float %y) {
437 ; CHECK-LABEL: @fmuladd_x_y_m0(
438 ; CHECK-NEXT: [[FMA:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
439 ; CHECK-NEXT: ret float [[FMA]]
441 %fma = call float @llvm.fmuladd.f32(float %x, float %y, float -0.0)
445 define float @fmuladd_x_1_z_fast(float %x, float %z) {
446 ; CHECK-LABEL: @fmuladd_x_1_z_fast(
447 ; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[X:%.*]], [[Z:%.*]]
448 ; CHECK-NEXT: ret float [[FMULADD]]
450 %fmuladd = call fast float @llvm.fmuladd.f32(float %x, float 1.0, float %z)
454 define <2 x double> @fmuladd_a_0_b(<2 x double> %a, <2 x double> %b) {
455 ; CHECK-LABEL: @fmuladd_a_0_b(
457 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
460 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
461 ret <2 x double> %res
464 define <2 x double> @fmuladd_0_a_b(<2 x double> %a, <2 x double> %b) {
465 ; CHECK-LABEL: @fmuladd_0_a_b(
467 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
470 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
471 ret <2 x double> %res
474 define <2 x double> @fmuladd_a_0_b_missing_flags(<2 x double> %a, <2 x double> %b) {
475 ; CHECK-LABEL: @fmuladd_a_0_b_missing_flags(
477 ; CHECK-NEXT: [[RES:%.*]] = call nnan <2 x double> @llvm.fmuladd.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
478 ; CHECK-NEXT: ret <2 x double> [[RES]]
481 %res = call nnan <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
482 ret <2 x double> %res
485 declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>)
487 define <2 x double> @fma_a_0_b(<2 x double> %a, <2 x double> %b) {
488 ; CHECK-LABEL: @fma_a_0_b(
490 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
493 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
494 ret <2 x double> %res
497 define <2 x double> @fma_0_a_b(<2 x double> %a, <2 x double> %b) {
498 ; CHECK-LABEL: @fma_0_a_b(
500 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
503 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
504 ret <2 x double> %res
507 define <2 x double> @fma_0_a_b_missing_flags(<2 x double> %a, <2 x double> %b) {
508 ; CHECK-LABEL: @fma_0_a_b_missing_flags(
510 ; CHECK-NEXT: [[RES:%.*]] = call nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
511 ; CHECK-NEXT: ret <2 x double> [[RES]]
514 %res = call nsz <2 x double> @llvm.fma.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
515 ret <2 x double> %res
518 define <2 x double> @fma_sqrt(<2 x double> %a, <2 x double> %b) {
519 ; CHECK-LABEL: @fma_sqrt(
521 ; CHECK-NEXT: [[RES:%.*]] = fadd fast <2 x double> [[A:%.*]], [[B:%.*]]
522 ; CHECK-NEXT: ret <2 x double> [[RES]]
525 %sqrt = call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> %a)
526 %res = call fast <2 x double> @llvm.fma.v2f64(<2 x double> %sqrt, <2 x double> %sqrt, <2 x double> %b)
527 ret <2 x double> %res
530 ; We do not fold constant multiplies in FMAs, as they could require rounding, unless either constant is 0.0 or 1.0.
531 define <2 x double> @fma_const_fmul(<2 x double> %b) {
532 ; CHECK-LABEL: @fma_const_fmul(
534 ; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 0x4131233302898702, double 0x40C387800000D6C0>, <2 x double> <double 1.291820e-08, double 9.123000e-06>, <2 x double> [[B:%.*]])
535 ; CHECK-NEXT: ret <2 x double> [[RES]]
538 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 1123123.0099110012314, double 9999.0000001>, <2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> %b)
539 ret <2 x double> %res
542 define <2 x double> @fma_const_fmul_zero(<2 x double> %b) {
543 ; CHECK-LABEL: @fma_const_fmul_zero(
545 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
548 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 0.0, double 0.0>, <2 x double> <double 1123123.0099110012314, double 9999.0000001>, <2 x double> %b)
549 ret <2 x double> %res
552 define <2 x double> @fma_const_fmul_zero2(<2 x double> %b) {
553 ; CHECK-LABEL: @fma_const_fmul_zero2(
555 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
558 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 1123123.0099110012314, double 9999.0000001>, <2 x double> <double 0.0, double 0.0>, <2 x double> %b)
559 ret <2 x double> %res
562 define <2 x double> @fma_const_fmul_one(<2 x double> %b) {
563 ; CHECK-LABEL: @fma_const_fmul_one(
565 ; CHECK-NEXT: [[RES:%.*]] = fadd nnan nsz <2 x double> [[B:%.*]], <double 0x4131233302898702, double 0x40C387800000D6C0>
566 ; CHECK-NEXT: ret <2 x double> [[RES]]
569 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 1.0, double 1.0>, <2 x double> <double 1123123.0099110012314, double 9999.0000001>, <2 x double> %b)
570 ret <2 x double> %res
573 define <2 x double> @fma_const_fmul_one2(<2 x double> %b) {
574 ; CHECK-LABEL: @fma_const_fmul_one2(
576 ; CHECK-NEXT: [[RES:%.*]] = fadd nnan nsz <2 x double> [[B:%.*]], <double 0x4131233302898702, double 0x40C387800000D6C0>
577 ; CHECK-NEXT: ret <2 x double> [[RES]]
580 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 1123123.0099110012314, double 9999.0000001>, <2 x double> <double 1.0, double 1.0>, <2 x double> %b)
581 ret <2 x double> %res
584 define <2 x double> @fma_nan_and_const_0(<2 x double> %b) {
585 ; CHECK-LABEL: @fma_nan_and_const_0(
587 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
590 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> %b)
591 ret <2 x double> %res
594 define <2 x double> @fma_nan_and_const_1(<2 x double> %b) {
595 ; CHECK-LABEL: @fma_nan_and_const_1(
597 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
600 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> %b)
601 ret <2 x double> %res
604 define <2 x double> @fma_nan_and_const_2(<2 x double> %b) {
605 ; CHECK-LABEL: @fma_nan_and_const_2(
607 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
610 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> %b, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>)
611 ret <2 x double> %res
614 define <2 x double> @fma_undef_0(<2 x double> %b, <2 x double> %c) {
615 ; CHECK-LABEL: @fma_undef_0(
617 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
620 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double undef, double undef>, <2 x double> %b, <2 x double> %c)
621 ret <2 x double> %res
624 define <2 x double> @fma_undef_1(<2 x double> %b, <2 x double> %c) {
625 ; CHECK-LABEL: @fma_undef_1(
627 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
630 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %b, <2 x double> <double undef, double undef>, <2 x double> %c)
631 ret <2 x double> %res
634 define <2 x double> @fma_undef_2(<2 x double> %b, <2 x double> %c) {
635 ; CHECK-LABEL: @fma_undef_2(
637 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
640 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %b, <2 x double> %c, <2 x double> <double undef, double undef>)
641 ret <2 x double> %res
644 define <2 x double> @fma_partial_undef_0(<2 x double> %b, <2 x double> %c) {
645 ; CHECK-LABEL: @fma_partial_undef_0(
647 ; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[B:%.*]], <2 x double> <double undef, double 0x4068E00A137F38C5>, <2 x double> [[C:%.*]])
648 ; CHECK-NEXT: ret <2 x double> [[RES]]
651 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double undef, double 199.00123>, <2 x double> %b, <2 x double> %c)
652 ret <2 x double> %res
655 define <2 x double> @fma_partial_undef_1(<2 x double> %b, <2 x double> %c) {
656 ; CHECK-LABEL: @fma_partial_undef_1(
658 ; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[B:%.*]], <2 x double> <double 0x4068E00A137F38C5, double undef>, <2 x double> [[C:%.*]])
659 ; CHECK-NEXT: ret <2 x double> [[RES]]
662 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %b, <2 x double> <double 199.00123, double undef>, <2 x double> %c)
663 ret <2 x double> %res
666 define <2 x double> @fma_partial_undef_2(<2 x double> %b, <2 x double> %c) {
667 ; CHECK-LABEL: @fma_partial_undef_2(
669 ; CHECK-NEXT: [[RES:%.*]] = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[B:%.*]], <2 x double> [[C:%.*]], <2 x double> <double 0x4068E00A137F38C5, double undef>)
670 ; CHECK-NEXT: ret <2 x double> [[RES]]
673 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %b, <2 x double> %c, <2 x double> <double 199.00123, double undef>)
674 ret <2 x double> %res
678 define <2 x double> @fma_nan_0(<2 x double> %b, <2 x double> %c) {
679 ; CHECK-LABEL: @fma_nan_0(
681 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
684 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> %b, <2 x double> %c)
685 ret <2 x double> %res
687 define <2 x double> @fma_nan_1(<2 x double> %b, <2 x double> %c) {
688 ; CHECK-LABEL: @fma_nan_1(
690 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
693 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %b, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> %c)
694 ret <2 x double> %res
697 define <2 x double> @fma_nan_2(<2 x double> %b, <2 x double> %c) {
698 ; CHECK-LABEL: @fma_nan_2(
700 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
703 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %b, <2 x double> %c, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>)
704 ret <2 x double> %res
707 define <2 x double> @fmuladd_const_fmul(<2 x double> %b) {
708 ; CHECK-LABEL: @fmuladd_const_fmul(
710 ; CHECK-NEXT: [[RES:%.*]] = fadd nnan nsz <2 x double> [[B:%.*]], <double 0x3F8DB6C076AD949B, double 0x3FB75A405B6E6D69>
711 ; CHECK-NEXT: ret <2 x double> [[RES]]
714 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> <double 1123123.0099110012314, double 9999.0000001>, <2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> %b)
715 ret <2 x double> %res
718 define <2 x double> @fmuladd_nan_and_const_0(<2 x double> %b) {
719 ; CHECK-LABEL: @fmuladd_nan_and_const_0(
721 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
724 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> %b)
725 ret <2 x double> %res
728 define <2 x double> @fmuladd_nan_and_const_1(<2 x double> %b) {
729 ; CHECK-LABEL: @fmuladd_nan_and_const_1(
731 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
734 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> %b)
735 ret <2 x double> %res
738 define <2 x double> @fmuladd_nan_and_const_2(<2 x double> %b) {
739 ; CHECK-LABEL: @fmuladd_nan_and_const_2(
741 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
744 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> <double 0.0000000129182, double 0.000009123>, <2 x double> %b, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>)
745 ret <2 x double> %res
748 define <2 x double> @fmuladd_nan_0(<2 x double> %b, <2 x double> %c) {
749 ; CHECK-LABEL: @fmuladd_nan_0(
751 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
754 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> %b, <2 x double> %c)
755 ret <2 x double> %res
758 define <2 x double> @fmuladd_nan_1(<2 x double> %b, <2 x double> %c) {
759 ; CHECK-LABEL: @fmuladd_nan_1(
761 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
764 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> %b, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, <2 x double> %c)
765 ret <2 x double> %res
768 define <2 x double> @fmuladd_undef_0(<2 x double> %b, <2 x double> %c) {
769 ; CHECK-LABEL: @fmuladd_undef_0(
771 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
774 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> <double undef, double undef>, <2 x double> %b, <2 x double> %c)
775 ret <2 x double> %res
778 define <2 x double> @fmuladd_undef_1(<2 x double> %b, <2 x double> %c) {
779 ; CHECK-LABEL: @fmuladd_undef_1(
781 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
784 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> %b, <2 x double> <double undef, double undef>, <2 x double> %c)
785 ret <2 x double> %res
788 define <2 x double> @fmuladd_undef_2(<2 x double> %b, <2 x double> %c) {
789 ; CHECK-LABEL: @fmuladd_undef_2(
791 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
794 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> %b, <2 x double> %c, <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>)
795 ret <2 x double> %res
797 declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>)
798 declare <2 x double> @llvm.sqrt.v2f64(<2 x double>)
801 attributes #0 = { nounwind }
802 attributes #1 = { nounwind readnone }