1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instcombine < %s | FileCheck %s
4 declare float @llvm.fma.f32(float, float, float)
5 declare <2 x float> @llvm.fma.v2f32(<2 x float>, <2 x float>, <2 x float>)
6 declare <3 x float> @llvm.fma.v3f32(<3 x float>, <3 x float>, <3 x float>)
7 declare <8 x half> @llvm.fma.v8f16(<8 x half>, <8 x half>, <8 x half>)
8 declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>)
10 declare float @llvm.fmuladd.f32(float, float, float)
11 declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>)
12 declare float @llvm.fabs.f32(float)
13 declare <2 x double> @llvm.sqrt.v2f64(<2 x double>)
14 declare void @use_vec(<2 x float>)
15 declare void @use_vec3(<3 x float>)
17 @external = external global i32
19 define float @fma_fneg_x_fneg_y(float %x, float %y, float %z) {
20 ; CHECK-LABEL: @fma_fneg_x_fneg_y(
21 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
22 ; CHECK-NEXT: ret float [[FMA]]
24 %x.fneg = fsub float -0.0, %x
25 %y.fneg = fsub float -0.0, %y
26 %fma = call float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
30 define float @fma_unary_fneg_x_unary_fneg_y(float %x, float %y, float %z) {
31 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y(
32 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
33 ; CHECK-NEXT: ret float [[FMA]]
35 %x.fneg = fneg float %x
36 %y.fneg = fneg float %y
37 %fma = call float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
41 define <2 x float> @fma_fneg_x_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
42 ; CHECK-LABEL: @fma_fneg_x_fneg_y_vec(
43 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
44 ; CHECK-NEXT: ret <2 x float> [[FMA]]
46 %xn = fsub <2 x float> <float -0.0, float -0.0>, %x
47 %yn = fsub <2 x float> <float -0.0, float -0.0>, %y
48 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z)
52 define <2 x float> @fma_unary_fneg_x_unary_fneg_y_vec(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
53 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y_vec(
54 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
55 ; CHECK-NEXT: ret <2 x float> [[FMA]]
57 %xn = fneg <2 x float> %x
58 %yn = fneg <2 x float> %y
59 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z)
63 define <2 x float> @fma_fneg_x_fneg_y_vec_poison(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
64 ; CHECK-LABEL: @fma_fneg_x_fneg_y_vec_poison(
65 ; CHECK-NEXT: [[FMA:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
66 ; CHECK-NEXT: ret <2 x float> [[FMA]]
68 %xn = fsub <2 x float> <float -0.0, float poison>, %x
69 %yn = fsub <2 x float> <float poison, float -0.0>, %y
70 %fma = call <2 x float> @llvm.fma.v2f32(<2 x float> %xn, <2 x float> %yn, <2 x float> %z)
74 define float @fma_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
75 ; CHECK-LABEL: @fma_fneg_x_fneg_y_fast(
76 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
77 ; CHECK-NEXT: ret float [[FMA]]
79 %x.fneg = fsub float -0.0, %x
80 %y.fneg = fsub float -0.0, %y
81 %fma = call fast float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
85 define float @fma_unary_fneg_x_unary_fneg_y_fast(float %x, float %y, float %z) {
86 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_y_fast(
87 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
88 ; CHECK-NEXT: ret float [[FMA]]
90 %x.fneg = fneg float %x
91 %y.fneg = fneg float %y
92 %fma = call fast float @llvm.fma.f32(float %x.fneg, float %y.fneg, float %z)
96 define float @fma_fneg_const_fneg_y(float %y, float %z) {
97 ; CHECK-LABEL: @fma_fneg_const_fneg_y(
98 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
99 ; CHECK-NEXT: ret float [[FMA]]
101 %y.fneg = fsub float -0.0, %y
102 %fsub = fsub float -0.0, bitcast (i32 ptrtoint (ptr @external to i32) to float)
103 %fma = call float @llvm.fma.f32(float %fsub, float %y.fneg, float %z)
107 define float @fma_unary_fneg_const_unary_fneg_y(float %y, float %z) {
108 ; CHECK-LABEL: @fma_unary_fneg_const_unary_fneg_y(
109 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
110 ; CHECK-NEXT: ret float [[FMA]]
112 %y.fneg = fneg float %y
113 %external.fneg = fneg float bitcast (i32 ptrtoint (ptr @external to i32) to float)
114 %fma = call float @llvm.fma.f32(float %external.fneg, float %y.fneg, float %z)
118 define float @fma_fneg_x_fneg_const(float %x, float %z) {
119 ; CHECK-LABEL: @fma_fneg_x_fneg_const(
120 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
121 ; CHECK-NEXT: ret float [[FMA]]
123 %x.fneg = fsub float -0.0, %x
124 %fsub = fsub float -0.0, bitcast (i32 ptrtoint (ptr @external to i32) to float)
125 %fma = call float @llvm.fma.f32(float %x.fneg, float %fsub, float %z)
129 define float @fma_unary_fneg_x_unary_fneg_const(float %x, float %z) {
130 ; CHECK-LABEL: @fma_unary_fneg_x_unary_fneg_const(
131 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
132 ; CHECK-NEXT: ret float [[FMA]]
134 %x.fneg = fneg float %x
135 %external.fneg = fneg float bitcast (i32 ptrtoint (ptr @external to i32) to float)
136 %fma = call float @llvm.fma.f32(float %x.fneg, float %external.fneg, float %z)
140 define float @fma_fabs_x_fabs_y(float %x, float %y, float %z) {
141 ; CHECK-LABEL: @fma_fabs_x_fabs_y(
142 ; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
143 ; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
144 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X_FABS]], float [[Y_FABS]], float [[Z:%.*]])
145 ; CHECK-NEXT: ret float [[FMA]]
147 %x.fabs = call float @llvm.fabs.f32(float %x)
148 %y.fabs = call float @llvm.fabs.f32(float %y)
149 %fma = call float @llvm.fma.f32(float %x.fabs, float %y.fabs, float %z)
153 define float @fma_fabs_x_fabs_x(float %x, float %z) {
154 ; CHECK-LABEL: @fma_fabs_x_fabs_x(
155 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
156 ; CHECK-NEXT: ret float [[FMA]]
158 %x.fabs = call float @llvm.fabs.f32(float %x)
159 %fma = call float @llvm.fma.f32(float %x.fabs, float %x.fabs, float %z)
163 define float @fma_fabs_x_fabs_x_fast(float %x, float %z) {
164 ; CHECK-LABEL: @fma_fabs_x_fabs_x_fast(
165 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
166 ; CHECK-NEXT: ret float [[FMA]]
168 %x.fabs = call float @llvm.fabs.f32(float %x)
169 %fma = call fast float @llvm.fma.f32(float %x.fabs, float %x.fabs, float %z)
173 define float @fmuladd_fneg_x_fneg_y(float %x, float %y, float %z) {
174 ; CHECK-LABEL: @fmuladd_fneg_x_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 = fsub float -0.0, %x
179 %y.fneg = fsub float -0.0, %y
180 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
184 define float @fmuladd_unary_fneg_x_unary_fneg_y(float %x, float %y, float %z) {
185 ; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_y(
186 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
187 ; CHECK-NEXT: ret float [[FMULADD]]
189 %x.fneg = fneg float %x
190 %y.fneg = fneg float %y
191 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
195 define float @fmuladd_fneg_x_fneg_y_fast(float %x, float %y, float %z) {
196 ; CHECK-LABEL: @fmuladd_fneg_x_fneg_y_fast(
197 ; CHECK-NEXT: [[FMULADD:%.*]] = call fast float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
198 ; CHECK-NEXT: ret float [[FMULADD]]
200 %x.fneg = fsub float -0.0, %x
201 %y.fneg = fsub float -0.0, %y
202 %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
206 define float @fmuladd_unfold(float %x, float %y, float %z) {
207 ; CHECK-LABEL: @fmuladd_unfold(
208 ; CHECK-NEXT: [[FMULADD:%.*]] = call reassoc contract float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
209 ; CHECK-NEXT: ret float [[FMULADD]]
211 %fmuladd = call reassoc contract float @llvm.fmuladd.f32(float %x, float %y, float %z)
215 define <8 x half> @fmuladd_unfold_vec(<8 x half> %x, <8 x half> %y, <8 x half> %z) {
216 ; CHECK-LABEL: @fmuladd_unfold_vec(
217 ; CHECK-NEXT: [[FMULADD:%.*]] = call reassoc contract <8 x half> @llvm.fmuladd.v8f16(<8 x half> [[X:%.*]], <8 x half> [[Y:%.*]], <8 x half> [[Z:%.*]])
218 ; CHECK-NEXT: ret <8 x half> [[FMULADD]]
220 %fmuladd = call reassoc contract <8 x half> @llvm.fmuladd.v8f16(<8 x half> %x, <8 x half> %y, <8 x half> %z)
221 ret <8 x half> %fmuladd
224 define float @fmuladd_unary_fneg_x_unary_fneg_y_fast(float %x, float %y, float %z) {
225 ; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_y_fast(
226 ; CHECK-NEXT: [[FMULADD:%.*]] = call fast float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float [[Z:%.*]])
227 ; CHECK-NEXT: ret float [[FMULADD]]
229 %x.fneg = fneg float %x
230 %y.fneg = fneg float %y
231 %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fneg, float %y.fneg, float %z)
235 define float @fmuladd_fneg_const_fneg_y(float %y, float %z) {
236 ; CHECK-LABEL: @fmuladd_fneg_const_fneg_y(
237 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
238 ; CHECK-NEXT: ret float [[FMULADD]]
240 %y.fneg = fsub float -0.0, %y
241 %fsub = fsub float -0.0, bitcast (i32 ptrtoint (ptr @external to i32) to float)
242 %fmuladd = call float @llvm.fmuladd.f32(float %fsub, float %y.fneg, float %z)
246 define float @fmuladd_unary_fneg_const_unary_fneg_y(float %y, float %z) {
247 ; CHECK-LABEL: @fmuladd_unary_fneg_const_unary_fneg_y(
248 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[Y:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
249 ; CHECK-NEXT: ret float [[FMULADD]]
251 %y.fneg = fneg float %y
252 %external.fneg = fneg float bitcast (i32 ptrtoint (ptr @external to i32) to float)
253 %fmuladd = call float @llvm.fmuladd.f32(float %external.fneg, float %y.fneg, float %z)
257 define float @fmuladd_fneg_x_fneg_const(float %x, float %z) {
258 ; CHECK-LABEL: @fmuladd_fneg_x_fneg_const(
259 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
260 ; CHECK-NEXT: ret float [[FMULADD]]
262 %x.fneg = fsub float -0.0, %x
263 %fsub = fsub float -0.0, bitcast (i32 ptrtoint (ptr @external to i32) to float)
264 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %fsub, float %z)
268 define float @fmuladd_unary_fneg_x_unary_fneg_const(float %x, float %z) {
269 ; CHECK-LABEL: @fmuladd_unary_fneg_x_unary_fneg_const(
270 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float bitcast (i32 ptrtoint (ptr @external to i32) to float), float [[Z:%.*]])
271 ; CHECK-NEXT: ret float [[FMULADD]]
273 %x.fneg = fneg float %x
274 %external.fneg = fneg float bitcast (i32 ptrtoint (ptr @external to i32) to float)
275 %fmuladd = call float @llvm.fmuladd.f32(float %x.fneg, float %external.fneg, float %z)
279 define float @fmuladd_fabs_x_fabs_y(float %x, float %y, float %z) {
280 ; CHECK-LABEL: @fmuladd_fabs_x_fabs_y(
281 ; CHECK-NEXT: [[X_FABS:%.*]] = call float @llvm.fabs.f32(float [[X:%.*]])
282 ; CHECK-NEXT: [[Y_FABS:%.*]] = call float @llvm.fabs.f32(float [[Y:%.*]])
283 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X_FABS]], float [[Y_FABS]], float [[Z:%.*]])
284 ; CHECK-NEXT: ret float [[FMULADD]]
286 %x.fabs = call float @llvm.fabs.f32(float %x)
287 %y.fabs = call float @llvm.fabs.f32(float %y)
288 %fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %y.fabs, float %z)
292 define float @fmuladd_fabs_x_fabs_x(float %x, float %z) {
293 ; CHECK-LABEL: @fmuladd_fabs_x_fabs_x(
294 ; CHECK-NEXT: [[FMULADD:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
295 ; CHECK-NEXT: ret float [[FMULADD]]
297 %x.fabs = call float @llvm.fabs.f32(float %x)
298 %fmuladd = call float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
302 define float @fmuladd_fabs_x_fabs_x_fast(float %x, float %z) {
303 ; CHECK-LABEL: @fmuladd_fabs_x_fabs_x_fast(
304 ; CHECK-NEXT: [[FMULADD:%.*]] = call fast float @llvm.fmuladd.f32(float [[X:%.*]], float [[X]], float [[Z:%.*]])
305 ; CHECK-NEXT: ret float [[FMULADD]]
307 %x.fabs = call float @llvm.fabs.f32(float %x)
308 %fmuladd = call fast float @llvm.fmuladd.f32(float %x.fabs, float %x.fabs, float %z)
312 define float @fma_k_y_z(float %y, float %z) {
313 ; CHECK-LABEL: @fma_k_y_z(
314 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
315 ; CHECK-NEXT: ret float [[FMA]]
317 %fma = call float @llvm.fma.f32(float 4.0, float %y, float %z)
321 define float @fma_k_y_z_fast(float %y, float %z) {
322 ; CHECK-LABEL: @fma_k_y_z_fast(
323 ; CHECK-NEXT: [[FMA:%.*]] = call fast float @llvm.fma.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
324 ; CHECK-NEXT: ret float [[FMA]]
326 %fma = call fast float @llvm.fma.f32(float 4.0, float %y, float %z)
330 ; Treat fmuladd like an fma intrinsic
331 define float @fmuladd_k_y_z_fast(float %y, float %z) {
332 ; CHECK-LABEL: @fmuladd_k_y_z_fast(
333 ; CHECK-NEXT: [[FMULADD:%.*]] = call fast float @llvm.fmuladd.f32(float [[Y:%.*]], float 4.000000e+00, float [[Z:%.*]])
334 ; CHECK-NEXT: ret float [[FMULADD]]
336 %fmuladd = call fast float @llvm.fmuladd.f32(float 4.0, float %y, float %z)
340 define float @fma_1_y_z(float %y, float %z) {
341 ; CHECK-LABEL: @fma_1_y_z(
342 ; CHECK-NEXT: [[FMA:%.*]] = fadd float [[Y:%.*]], [[Z:%.*]]
343 ; CHECK-NEXT: ret float [[FMA]]
345 %fma = call float @llvm.fma.f32(float 1.0, float %y, float %z)
349 define float @fma_x_1_z(float %x, float %z) {
350 ; CHECK-LABEL: @fma_x_1_z(
351 ; CHECK-NEXT: [[FMA:%.*]] = fadd float [[X:%.*]], [[Z:%.*]]
352 ; CHECK-NEXT: ret float [[FMA]]
354 %fma = call float @llvm.fma.f32(float %x, float 1.0, float %z)
358 define <2 x float> @fma_x_1_z_v2f32(<2 x float> %x, <2 x float> %z) {
359 ; CHECK-LABEL: @fma_x_1_z_v2f32(
360 ; CHECK-NEXT: [[FMA:%.*]] = fadd <2 x float> [[X:%.*]], [[Z:%.*]]
361 ; CHECK-NEXT: ret <2 x float> [[FMA]]
363 %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)
367 define <2 x float> @fma_x_1_2_z_v2f32(<2 x float> %x, <2 x float> %z) {
368 ; CHECK-LABEL: @fma_x_1_2_z_v2f32(
369 ; 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:%.*]])
370 ; CHECK-NEXT: ret <2 x float> [[FMA]]
372 %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)
376 define float @fma_x_1_z_fast(float %x, float %z) {
377 ; CHECK-LABEL: @fma_x_1_z_fast(
378 ; CHECK-NEXT: [[FMA:%.*]] = fadd fast float [[X:%.*]], [[Z:%.*]]
379 ; CHECK-NEXT: ret float [[FMA]]
381 %fma = call fast float @llvm.fma.f32(float %x, float 1.0, float %z)
385 define float @fma_1_1_z(float %z) {
386 ; CHECK-LABEL: @fma_1_1_z(
387 ; CHECK-NEXT: [[FMA:%.*]] = fadd float [[Z:%.*]], 1.000000e+00
388 ; CHECK-NEXT: ret float [[FMA]]
390 %fma = call float @llvm.fma.f32(float 1.0, float 1.0, float %z)
394 define float @fma_x_y_0(float %x, float %y) {
395 ; CHECK-LABEL: @fma_x_y_0(
396 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float 0.000000e+00)
397 ; CHECK-NEXT: ret float [[FMA]]
399 %fma = call float @llvm.fma.f32(float %x, float %y, float 0.0)
403 define float @fma_x_y_0_nsz(float %x, float %y) {
404 ; CHECK-LABEL: @fma_x_y_0_nsz(
405 ; CHECK-NEXT: [[FMA:%.*]] = fmul nsz float [[X:%.*]], [[Y:%.*]]
406 ; CHECK-NEXT: ret float [[FMA]]
408 %fma = call nsz float @llvm.fma.f32(float %x, float %y, float 0.0)
412 define <8 x half> @fma_x_y_0_v(<8 x half> %x, <8 x half> %y) {
413 ; CHECK-LABEL: @fma_x_y_0_v(
414 ; CHECK-NEXT: [[FMA:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> [[X:%.*]], <8 x half> [[Y:%.*]], <8 x half> zeroinitializer)
415 ; CHECK-NEXT: ret <8 x half> [[FMA]]
417 %fma = call <8 x half> @llvm.fma.v8f16(<8 x half> %x, <8 x half> %y, <8 x half> zeroinitializer)
421 define <8 x half> @fma_x_y_0_nsz_v(<8 x half> %x, <8 x half> %y) {
422 ; CHECK-LABEL: @fma_x_y_0_nsz_v(
423 ; CHECK-NEXT: [[FMA:%.*]] = fmul nsz <8 x half> [[X:%.*]], [[Y:%.*]]
424 ; CHECK-NEXT: ret <8 x half> [[FMA]]
426 %fma = call nsz <8 x half> @llvm.fma.v8f16(<8 x half> %x, <8 x half> %y, <8 x half> zeroinitializer)
430 define float @fmuladd_x_y_0(float %x, float %y) {
431 ; CHECK-LABEL: @fmuladd_x_y_0(
432 ; CHECK-NEXT: [[FMA:%.*]] = call float @llvm.fmuladd.f32(float [[X:%.*]], float [[Y:%.*]], float 0.000000e+00)
433 ; CHECK-NEXT: ret float [[FMA]]
435 %fma = call float @llvm.fmuladd.f32(float %x, float %y, float 0.0)
439 define float @fmuladd_x_y_0_nsz(float %x, float %y) {
440 ; CHECK-LABEL: @fmuladd_x_y_0_nsz(
441 ; CHECK-NEXT: [[FMA:%.*]] = fmul nsz float [[X:%.*]], [[Y:%.*]]
442 ; CHECK-NEXT: ret float [[FMA]]
444 %fma = call nsz float @llvm.fmuladd.f32(float %x, float %y, float 0.0)
448 define float @fma_x_y_m0(float %x, float %y) {
449 ; CHECK-LABEL: @fma_x_y_m0(
450 ; CHECK-NEXT: [[FMA:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
451 ; CHECK-NEXT: ret float [[FMA]]
453 %fma = call float @llvm.fma.f32(float %x, float %y, float -0.0)
457 define <8 x half> @fma_x_y_m0_v(<8 x half> %x, <8 x half> %y) {
458 ; CHECK-LABEL: @fma_x_y_m0_v(
459 ; CHECK-NEXT: [[FMA:%.*]] = fmul <8 x half> [[X:%.*]], [[Y:%.*]]
460 ; CHECK-NEXT: ret <8 x half> [[FMA]]
462 %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>)
466 define float @fmuladd_x_y_m0(float %x, float %y) {
467 ; CHECK-LABEL: @fmuladd_x_y_m0(
468 ; CHECK-NEXT: [[FMA:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
469 ; CHECK-NEXT: ret float [[FMA]]
471 %fma = call float @llvm.fmuladd.f32(float %x, float %y, float -0.0)
475 define float @fmuladd_x_1_z_fast(float %x, float %z) {
476 ; CHECK-LABEL: @fmuladd_x_1_z_fast(
477 ; CHECK-NEXT: [[FMULADD:%.*]] = fadd fast float [[X:%.*]], [[Z:%.*]]
478 ; CHECK-NEXT: ret float [[FMULADD]]
480 %fmuladd = call fast float @llvm.fmuladd.f32(float %x, float 1.0, float %z)
484 define <2 x double> @fmuladd_a_0_b(<2 x double> %a, <2 x double> %b) {
485 ; CHECK-LABEL: @fmuladd_a_0_b(
486 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
488 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
489 ret <2 x double> %res
492 define <2 x double> @fmuladd_0_a_b(<2 x double> %a, <2 x double> %b) {
493 ; CHECK-LABEL: @fmuladd_0_a_b(
494 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
496 %res = call nnan nsz <2 x double> @llvm.fmuladd.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
497 ret <2 x double> %res
500 define <2 x double> @fmuladd_a_0_b_missing_flags(<2 x double> %a, <2 x double> %b) {
501 ; CHECK-LABEL: @fmuladd_a_0_b_missing_flags(
502 ; CHECK-NEXT: [[RES:%.*]] = call nnan <2 x double> @llvm.fmuladd.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
503 ; CHECK-NEXT: ret <2 x double> [[RES]]
505 %res = call nnan <2 x double> @llvm.fmuladd.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
506 ret <2 x double> %res
509 define <2 x double> @fma_a_0_b(<2 x double> %a, <2 x double> %b) {
510 ; CHECK-LABEL: @fma_a_0_b(
511 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
513 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> %a, <2 x double> zeroinitializer, <2 x double> %b)
514 ret <2 x double> %res
517 define <2 x double> @fma_0_a_b(<2 x double> %a, <2 x double> %b) {
518 ; CHECK-LABEL: @fma_0_a_b(
519 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
521 %res = call nnan nsz <2 x double> @llvm.fma.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
522 ret <2 x double> %res
525 define <2 x double> @fma_0_a_b_missing_flags(<2 x double> %a, <2 x double> %b) {
526 ; CHECK-LABEL: @fma_0_a_b_missing_flags(
527 ; CHECK-NEXT: [[RES:%.*]] = call nsz <2 x double> @llvm.fma.v2f64(<2 x double> [[A:%.*]], <2 x double> zeroinitializer, <2 x double> [[B:%.*]])
528 ; CHECK-NEXT: ret <2 x double> [[RES]]
530 %res = call nsz <2 x double> @llvm.fma.v2f64(<2 x double> zeroinitializer, <2 x double> %a, <2 x double> %b)
531 ret <2 x double> %res
534 define <2 x double> @fma_sqrt(<2 x double> %a, <2 x double> %b) {
535 ; CHECK-LABEL: @fma_sqrt(
536 ; CHECK-NEXT: [[RES:%.*]] = fadd fast <2 x double> [[A:%.*]], [[B:%.*]]
537 ; CHECK-NEXT: ret <2 x double> [[RES]]
539 %sqrt = call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> %a)
540 %res = call fast <2 x double> @llvm.fma.v2f64(<2 x double> %sqrt, <2 x double> %sqrt, <2 x double> %b)
541 ret <2 x double> %res
544 ; We do not fold constant multiplies in FMAs, as they could require rounding, unless either constant is 0.0 or 1.0.
545 define <2 x double> @fma_const_fmul(<2 x double> %b) {
546 ; CHECK-LABEL: @fma_const_fmul(
547 ; 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:%.*]])
548 ; CHECK-NEXT: ret <2 x double> [[RES]]
550 %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)
551 ret <2 x double> %res
554 define <2 x double> @fma_const_fmul_zero(<2 x double> %b) {
555 ; CHECK-LABEL: @fma_const_fmul_zero(
556 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
558 %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)
559 ret <2 x double> %res
562 define <2 x double> @fma_const_fmul_zero2(<2 x double> %b) {
563 ; CHECK-LABEL: @fma_const_fmul_zero2(
564 ; CHECK-NEXT: ret <2 x double> [[B:%.*]]
566 %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)
567 ret <2 x double> %res
570 define <2 x double> @fma_const_fmul_one(<2 x double> %b) {
571 ; CHECK-LABEL: @fma_const_fmul_one(
572 ; CHECK-NEXT: [[RES:%.*]] = fadd nnan nsz <2 x double> [[B:%.*]], <double 0x4131233302898702, double 0x40C387800000D6C0>
573 ; CHECK-NEXT: ret <2 x double> [[RES]]
575 %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)
576 ret <2 x double> %res
579 define <2 x double> @fma_const_fmul_one2(<2 x double> %b) {
580 ; CHECK-LABEL: @fma_const_fmul_one2(
581 ; CHECK-NEXT: [[RES:%.*]] = fadd nnan nsz <2 x double> [[B:%.*]], <double 0x4131233302898702, double 0x40C387800000D6C0>
582 ; CHECK-NEXT: ret <2 x double> [[RES]]
584 %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)
585 ret <2 x double> %res
588 define <2 x double> @fma_nan_and_const_0(<2 x double> %b) {
589 ; CHECK-LABEL: @fma_nan_and_const_0(
590 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
592 %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)
593 ret <2 x double> %res
596 define <2 x double> @fma_nan_and_const_1(<2 x double> %b) {
597 ; CHECK-LABEL: @fma_nan_and_const_1(
598 ; 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(
606 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
608 %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>)
609 ret <2 x double> %res
612 define <2 x double> @fma_undef_0(<2 x double> %b, <2 x double> %c) {
613 ; CHECK-LABEL: @fma_undef_0(
614 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
616 %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)
617 ret <2 x double> %res
620 define <2 x double> @fma_undef_1(<2 x double> %b, <2 x double> %c) {
621 ; CHECK-LABEL: @fma_undef_1(
622 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
624 %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)
625 ret <2 x double> %res
628 define <2 x double> @fma_undef_2(<2 x double> %b, <2 x double> %c) {
629 ; CHECK-LABEL: @fma_undef_2(
630 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
632 %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>)
633 ret <2 x double> %res
636 define <2 x double> @fma_partial_undef_0(<2 x double> %b, <2 x double> %c) {
637 ; CHECK-LABEL: @fma_partial_undef_0(
638 ; 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:%.*]])
639 ; CHECK-NEXT: ret <2 x double> [[RES]]
641 %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)
642 ret <2 x double> %res
645 define <2 x double> @fma_partial_undef_1(<2 x double> %b, <2 x double> %c) {
646 ; CHECK-LABEL: @fma_partial_undef_1(
647 ; 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:%.*]])
648 ; CHECK-NEXT: ret <2 x double> [[RES]]
650 %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)
651 ret <2 x double> %res
654 define <2 x double> @fma_partial_undef_2(<2 x double> %b, <2 x double> %c) {
655 ; CHECK-LABEL: @fma_partial_undef_2(
656 ; 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>)
657 ; CHECK-NEXT: ret <2 x double> [[RES]]
659 %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>)
660 ret <2 x double> %res
664 define <2 x double> @fma_nan_0(<2 x double> %b, <2 x double> %c) {
665 ; CHECK-LABEL: @fma_nan_0(
666 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
668 %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)
669 ret <2 x double> %res
671 define <2 x double> @fma_nan_1(<2 x double> %b, <2 x double> %c) {
672 ; CHECK-LABEL: @fma_nan_1(
673 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
675 %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)
676 ret <2 x double> %res
679 define <2 x double> @fma_nan_2(<2 x double> %b, <2 x double> %c) {
680 ; CHECK-LABEL: @fma_nan_2(
681 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
683 %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>)
684 ret <2 x double> %res
687 define <2 x double> @fmuladd_const_fmul(<2 x double> %b) {
688 ; CHECK-LABEL: @fmuladd_const_fmul(
689 ; CHECK-NEXT: [[RES:%.*]] = fadd nnan nsz <2 x double> [[B:%.*]], <double 0x3F8DB6C076AD949B, double 0x3FB75A405B6E6D69>
690 ; CHECK-NEXT: ret <2 x double> [[RES]]
692 %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)
693 ret <2 x double> %res
696 define <2 x double> @fmuladd_nan_and_const_0(<2 x double> %b) {
697 ; CHECK-LABEL: @fmuladd_nan_and_const_0(
698 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
700 %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)
701 ret <2 x double> %res
704 define <2 x double> @fmuladd_nan_and_const_1(<2 x double> %b) {
705 ; CHECK-LABEL: @fmuladd_nan_and_const_1(
706 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
708 %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)
709 ret <2 x double> %res
712 define <2 x double> @fmuladd_nan_and_const_2(<2 x double> %b) {
713 ; CHECK-LABEL: @fmuladd_nan_and_const_2(
714 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
716 %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>)
717 ret <2 x double> %res
720 define <2 x double> @fmuladd_nan_0(<2 x double> %b, <2 x double> %c) {
721 ; CHECK-LABEL: @fmuladd_nan_0(
722 ; 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> %b, <2 x double> %c)
725 ret <2 x double> %res
728 define <2 x double> @fmuladd_nan_1(<2 x double> %b, <2 x double> %c) {
729 ; CHECK-LABEL: @fmuladd_nan_1(
730 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
732 %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)
733 ret <2 x double> %res
736 define <2 x double> @fmuladd_undef_0(<2 x double> %b, <2 x double> %c) {
737 ; CHECK-LABEL: @fmuladd_undef_0(
738 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
740 %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)
741 ret <2 x double> %res
744 define <2 x double> @fmuladd_undef_1(<2 x double> %b, <2 x double> %c) {
745 ; CHECK-LABEL: @fmuladd_undef_1(
746 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
748 %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)
749 ret <2 x double> %res
752 define <2 x double> @fmuladd_undef_2(<2 x double> %b, <2 x double> %c) {
753 ; CHECK-LABEL: @fmuladd_undef_2(
754 ; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>
756 %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>)
757 ret <2 x double> %res
760 define <2 x float> @fma_unary_shuffle_ops(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
761 ; CHECK-LABEL: @fma_unary_shuffle_ops(
762 ; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[X:%.*]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
763 ; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
764 ; CHECK-NEXT: ret <2 x float> [[R]]
766 %a = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> <i32 1, i32 0>
767 %b = shufflevector <2 x float> %y, <2 x float> poison, <2 x i32> <i32 1, i32 0>
768 %c = shufflevector <2 x float> %z, <2 x float> poison, <2 x i32> <i32 1, i32 0>
769 %r = call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c)
773 define <3 x float> @fma_unary_shuffle_ops_widening(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
774 ; CHECK-LABEL: @fma_unary_shuffle_ops_widening(
775 ; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 1>
776 ; CHECK-NEXT: call void @use_vec3(<3 x float> [[A]])
777 ; CHECK-NEXT: [[TMP1:%.*]] = call fast <2 x float> @llvm.fma.v2f32(<2 x float> [[X]], <2 x float> [[Y:%.*]], <2 x float> [[Z:%.*]])
778 ; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 1>
779 ; CHECK-NEXT: ret <3 x float> [[R]]
781 %a = shufflevector <2 x float> %x, <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 1>
782 call void @use_vec3(<3 x float> %a)
783 %b = shufflevector <2 x float> %y, <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 1>
784 %c = shufflevector <2 x float> %z, <2 x float> poison, <3 x i32> <i32 1, i32 0, i32 1>
785 %r = call fast <3 x float> @llvm.fma.v3f32(<3 x float> %a, <3 x float> %b, <3 x float> %c)
789 define <2 x float> @fma_unary_shuffle_ops_narrowing(<3 x float> %x, <3 x float> %y, <3 x float> %z) {
790 ; CHECK-LABEL: @fma_unary_shuffle_ops_narrowing(
791 ; CHECK-NEXT: [[B:%.*]] = shufflevector <3 x float> [[Y:%.*]], <3 x float> poison, <2 x i32> <i32 1, i32 0>
792 ; CHECK-NEXT: call void @use_vec(<2 x float> [[B]])
793 ; CHECK-NEXT: [[TMP1:%.*]] = call nnan nsz <3 x float> @llvm.fma.v3f32(<3 x float> [[X:%.*]], <3 x float> [[Y]], <3 x float> [[Z:%.*]])
794 ; CHECK-NEXT: [[R:%.*]] = shufflevector <3 x float> [[TMP1]], <3 x float> poison, <2 x i32> <i32 1, i32 0>
795 ; CHECK-NEXT: ret <2 x float> [[R]]
797 %a = shufflevector <3 x float> %x, <3 x float> poison, <2 x i32> <i32 1, i32 0>
798 %b = shufflevector <3 x float> %y, <3 x float> poison, <2 x i32> <i32 1, i32 0>
799 call void @use_vec(<2 x float> %b)
800 %c = shufflevector <3 x float> %z, <3 x float> poison, <2 x i32> <i32 1, i32 0>
801 %r = call nnan nsz <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c)
805 ; negative test - must have 3 shuffles
807 define <2 x float> @fma_unary_shuffle_ops_unshuffled(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
808 ; CHECK-LABEL: @fma_unary_shuffle_ops_unshuffled(
809 ; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
810 ; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
811 ; CHECK-NEXT: [[R:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[A]], <2 x float> [[B]], <2 x float> [[Z:%.*]])
812 ; CHECK-NEXT: ret <2 x float> [[R]]
814 %a = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> <i32 1, i32 0>
815 %b = shufflevector <2 x float> %y, <2 x float> poison, <2 x i32> <i32 1, i32 0>
816 %r = call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %z)
820 ; negative test - must have identical masks
822 define <2 x float> @fma_unary_shuffle_ops_wrong_mask(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
823 ; CHECK-LABEL: @fma_unary_shuffle_ops_wrong_mask(
824 ; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
825 ; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y:%.*]], <2 x float> poison, <2 x i32> zeroinitializer
826 ; CHECK-NEXT: [[C:%.*]] = shufflevector <2 x float> [[Z:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
827 ; CHECK-NEXT: [[R:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[A]], <2 x float> [[B]], <2 x float> [[C]])
828 ; CHECK-NEXT: ret <2 x float> [[R]]
830 %a = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> <i32 1, i32 0>
831 %b = shufflevector <2 x float> %y, <2 x float> poison, <2 x i32> <i32 0, i32 0>
832 %c = shufflevector <2 x float> %z, <2 x float> poison, <2 x i32> <i32 1, i32 0>
833 %r = call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c)
837 ; negative test - too many uses
839 define <2 x float> @fma_unary_shuffle_ops_uses(<2 x float> %x, <2 x float> %y, <2 x float> %z) {
840 ; CHECK-LABEL: @fma_unary_shuffle_ops_uses(
841 ; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
842 ; CHECK-NEXT: call void @use_vec(<2 x float> [[A]])
843 ; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x float> [[Y:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
844 ; CHECK-NEXT: call void @use_vec(<2 x float> [[B]])
845 ; CHECK-NEXT: [[C:%.*]] = shufflevector <2 x float> [[Z:%.*]], <2 x float> poison, <2 x i32> <i32 1, i32 0>
846 ; CHECK-NEXT: call void @use_vec(<2 x float> [[C]])
847 ; CHECK-NEXT: [[R:%.*]] = call <2 x float> @llvm.fma.v2f32(<2 x float> [[A]], <2 x float> [[B]], <2 x float> [[C]])
848 ; CHECK-NEXT: ret <2 x float> [[R]]
850 %a = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> <i32 1, i32 0>
851 call void @use_vec(<2 x float> %a)
852 %b = shufflevector <2 x float> %y, <2 x float> poison, <2 x i32> <i32 1, i32 0>
853 call void @use_vec(<2 x float> %b)
854 %c = shufflevector <2 x float> %z, <2 x float> poison, <2 x i32> <i32 1, i32 0>
855 call void @use_vec(<2 x float> %c)
856 %r = call <2 x float> @llvm.fma.v2f32(<2 x float> %a, <2 x float> %b, <2 x float> %c)