1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefixes=ALL,SSE
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx | FileCheck %s --check-prefixes=ALL,AVX
5 define <4 x float> @fadd_op1_constant_v4f32(float %x) nounwind {
6 ; SSE-LABEL: fadd_op1_constant_v4f32:
8 ; SSE-NEXT: addss {{.*}}(%rip), %xmm0
11 ; AVX-LABEL: fadd_op1_constant_v4f32:
13 ; AVX-NEXT: vaddss {{.*}}(%rip), %xmm0, %xmm0
15 %v = insertelement <4 x float> undef, float %x, i32 0
16 %b = fadd <4 x float> %v, <float 42.0, float undef, float undef, float undef>
20 define <4 x float> @load_fadd_op1_constant_v4f32(float* %p) nounwind {
21 ; SSE-LABEL: load_fadd_op1_constant_v4f32:
23 ; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
24 ; SSE-NEXT: addss {{.*}}(%rip), %xmm0
27 ; AVX-LABEL: load_fadd_op1_constant_v4f32:
29 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
30 ; AVX-NEXT: vaddss {{.*}}(%rip), %xmm0, %xmm0
32 %x = load float, float* %p
33 %v = insertelement <4 x float> undef, float %x, i32 0
34 %b = fadd <4 x float> %v, <float 42.0, float undef, float undef, float undef>
38 define <4 x float> @fsub_op0_constant_v4f32(float %x) nounwind {
39 ; SSE-LABEL: fsub_op0_constant_v4f32:
41 ; SSE-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
42 ; SSE-NEXT: subss %xmm0, %xmm1
43 ; SSE-NEXT: movaps %xmm1, %xmm0
46 ; AVX-LABEL: fsub_op0_constant_v4f32:
48 ; AVX-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
49 ; AVX-NEXT: vsubss %xmm0, %xmm1, %xmm0
51 %v = insertelement <4 x float> undef, float %x, i32 0
52 %b = fsub <4 x float> <float 42.0, float undef, float undef, float undef>, %v
56 define <4 x float> @load_fsub_op0_constant_v4f32(float* %p) nounwind {
57 ; SSE-LABEL: load_fsub_op0_constant_v4f32:
59 ; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
60 ; SSE-NEXT: subss (%rdi), %xmm0
63 ; AVX-LABEL: load_fsub_op0_constant_v4f32:
65 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
66 ; AVX-NEXT: vsubss (%rdi), %xmm0, %xmm0
68 %x = load float, float* %p
69 %v = insertelement <4 x float> undef, float %x, i32 0
70 %b = fsub <4 x float> <float 42.0, float undef, float undef, float undef>, %v
74 define <4 x float> @fmul_op1_constant_v4f32(float %x) nounwind {
75 ; SSE-LABEL: fmul_op1_constant_v4f32:
77 ; SSE-NEXT: mulss {{.*}}(%rip), %xmm0
80 ; AVX-LABEL: fmul_op1_constant_v4f32:
82 ; AVX-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
84 %v = insertelement <4 x float> undef, float %x, i32 0
85 %b = fmul <4 x float> %v, <float 42.0, float undef, float undef, float undef>
89 define <4 x float> @load_fmul_op1_constant_v4f32(float* %p) nounwind {
90 ; SSE-LABEL: load_fmul_op1_constant_v4f32:
92 ; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
93 ; SSE-NEXT: mulss {{.*}}(%rip), %xmm0
96 ; AVX-LABEL: load_fmul_op1_constant_v4f32:
98 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
99 ; AVX-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
101 %x = load float, float* %p
102 %v = insertelement <4 x float> undef, float %x, i32 0
103 %b = fmul <4 x float> %v, <float 42.0, float undef, float undef, float undef>
107 define <4 x float> @fdiv_op1_constant_v4f32(float %x) nounwind {
108 ; SSE-LABEL: fdiv_op1_constant_v4f32:
110 ; SSE-NEXT: divss {{.*}}(%rip), %xmm0
113 ; AVX-LABEL: fdiv_op1_constant_v4f32:
115 ; AVX-NEXT: vdivss {{.*}}(%rip), %xmm0, %xmm0
117 %v = insertelement <4 x float> undef, float %x, i32 0
118 %b = fdiv <4 x float> %v, <float 42.0, float undef, float undef, float undef>
122 define <4 x float> @load_fdiv_op1_constant_v4f32(float* %p) nounwind {
123 ; SSE-LABEL: load_fdiv_op1_constant_v4f32:
125 ; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
126 ; SSE-NEXT: divss {{.*}}(%rip), %xmm0
129 ; AVX-LABEL: load_fdiv_op1_constant_v4f32:
131 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
132 ; AVX-NEXT: vdivss {{.*}}(%rip), %xmm0, %xmm0
134 %x = load float, float* %p
135 %v = insertelement <4 x float> undef, float %x, i32 0
136 %b = fdiv <4 x float> %v, <float 42.0, float undef, float undef, float undef>
140 define <4 x float> @fdiv_op0_constant_v4f32(float %x) nounwind {
141 ; SSE-LABEL: fdiv_op0_constant_v4f32:
143 ; SSE-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
144 ; SSE-NEXT: divss %xmm0, %xmm1
145 ; SSE-NEXT: movaps %xmm1, %xmm0
148 ; AVX-LABEL: fdiv_op0_constant_v4f32:
150 ; AVX-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
151 ; AVX-NEXT: vdivss %xmm0, %xmm1, %xmm0
153 %v = insertelement <4 x float> undef, float %x, i32 0
154 %b = fdiv <4 x float> <float 42.0, float undef, float undef, float undef>, %v
158 define <4 x float> @load_fdiv_op0_constant_v4f32(float* %p) nounwind {
159 ; SSE-LABEL: load_fdiv_op0_constant_v4f32:
161 ; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
162 ; SSE-NEXT: divss (%rdi), %xmm0
165 ; AVX-LABEL: load_fdiv_op0_constant_v4f32:
167 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
168 ; AVX-NEXT: vdivss (%rdi), %xmm0, %xmm0
170 %x = load float, float* %p
171 %v = insertelement <4 x float> undef, float %x, i32 0
172 %b = fdiv <4 x float> <float 42.0, float undef, float undef, float undef>, %v
176 define <4 x double> @fadd_op1_constant_v4f64(double %x) nounwind {
177 ; SSE-LABEL: fadd_op1_constant_v4f64:
179 ; SSE-NEXT: addsd {{.*}}(%rip), %xmm0
182 ; AVX-LABEL: fadd_op1_constant_v4f64:
184 ; AVX-NEXT: vaddsd {{.*}}(%rip), %xmm0, %xmm0
186 %v = insertelement <4 x double> undef, double %x, i32 0
187 %b = fadd <4 x double> %v, <double 42.0, double undef, double undef, double undef>
191 define <4 x double> @load_fadd_op1_constant_v4f64(double* %p) nounwind {
192 ; SSE-LABEL: load_fadd_op1_constant_v4f64:
194 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
195 ; SSE-NEXT: addsd {{.*}}(%rip), %xmm0
198 ; AVX-LABEL: load_fadd_op1_constant_v4f64:
200 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
201 ; AVX-NEXT: vaddsd {{.*}}(%rip), %xmm0, %xmm0
203 %x = load double, double* %p
204 %v = insertelement <4 x double> undef, double %x, i32 0
205 %b = fadd <4 x double> %v, <double 42.0, double undef, double undef, double undef>
209 define <4 x double> @fsub_op0_constant_v4f64(double %x) nounwind {
210 ; SSE-LABEL: fsub_op0_constant_v4f64:
212 ; SSE-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
213 ; SSE-NEXT: subsd %xmm0, %xmm1
214 ; SSE-NEXT: movapd %xmm1, %xmm0
217 ; AVX-LABEL: fsub_op0_constant_v4f64:
219 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
220 ; AVX-NEXT: vsubsd %xmm0, %xmm1, %xmm0
222 %v = insertelement <4 x double> undef, double %x, i32 0
223 %b = fsub <4 x double> <double 42.0, double undef, double undef, double undef>, %v
227 define <4 x double> @load_fsub_op0_constant_v4f64(double* %p) nounwind {
228 ; SSE-LABEL: load_fsub_op0_constant_v4f64:
230 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
231 ; SSE-NEXT: subsd (%rdi), %xmm0
234 ; AVX-LABEL: load_fsub_op0_constant_v4f64:
236 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
237 ; AVX-NEXT: vsubsd (%rdi), %xmm0, %xmm0
239 %x = load double, double* %p
240 %v = insertelement <4 x double> undef, double %x, i32 0
241 %b = fsub <4 x double> <double 42.0, double undef, double undef, double undef>, %v
245 define <4 x double> @fmul_op1_constant_v4f64(double %x) nounwind {
246 ; SSE-LABEL: fmul_op1_constant_v4f64:
248 ; SSE-NEXT: mulsd {{.*}}(%rip), %xmm0
251 ; AVX-LABEL: fmul_op1_constant_v4f64:
253 ; AVX-NEXT: vmulsd {{.*}}(%rip), %xmm0, %xmm0
255 %v = insertelement <4 x double> undef, double %x, i32 0
256 %b = fmul <4 x double> %v, <double 42.0, double undef, double undef, double undef>
260 define <4 x double> @load_fmul_op1_constant_v4f64(double* %p) nounwind {
261 ; SSE-LABEL: load_fmul_op1_constant_v4f64:
263 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
264 ; SSE-NEXT: mulsd {{.*}}(%rip), %xmm0
267 ; AVX-LABEL: load_fmul_op1_constant_v4f64:
269 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
270 ; AVX-NEXT: vmulsd {{.*}}(%rip), %xmm0, %xmm0
272 %x = load double, double* %p
273 %v = insertelement <4 x double> undef, double %x, i32 0
274 %b = fmul <4 x double> %v, <double 42.0, double undef, double undef, double undef>
278 define <4 x double> @fdiv_op1_constant_v4f64(double %x) nounwind {
279 ; SSE-LABEL: fdiv_op1_constant_v4f64:
281 ; SSE-NEXT: divsd {{.*}}(%rip), %xmm0
284 ; AVX-LABEL: fdiv_op1_constant_v4f64:
286 ; AVX-NEXT: vdivsd {{.*}}(%rip), %xmm0, %xmm0
288 %v = insertelement <4 x double> undef, double %x, i32 0
289 %b = fdiv <4 x double> %v, <double 42.0, double undef, double undef, double undef>
293 define <4 x double> @load_fdiv_op1_constant_v4f64(double* %p) nounwind {
294 ; SSE-LABEL: load_fdiv_op1_constant_v4f64:
296 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
297 ; SSE-NEXT: divsd {{.*}}(%rip), %xmm0
300 ; AVX-LABEL: load_fdiv_op1_constant_v4f64:
302 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
303 ; AVX-NEXT: vdivsd {{.*}}(%rip), %xmm0, %xmm0
305 %x = load double, double* %p
306 %v = insertelement <4 x double> undef, double %x, i32 0
307 %b = fdiv <4 x double> %v, <double 42.0, double undef, double undef, double undef>
311 define <4 x double> @fdiv_op0_constant_v4f64(double %x) nounwind {
312 ; SSE-LABEL: fdiv_op0_constant_v4f64:
314 ; SSE-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
315 ; SSE-NEXT: divsd %xmm0, %xmm1
316 ; SSE-NEXT: movapd %xmm1, %xmm0
319 ; AVX-LABEL: fdiv_op0_constant_v4f64:
321 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
322 ; AVX-NEXT: vdivsd %xmm0, %xmm1, %xmm0
324 %v = insertelement <4 x double> undef, double %x, i32 0
325 %b = fdiv <4 x double> <double 42.0, double undef, double undef, double undef>, %v
329 define <4 x double> @load_fdiv_op0_constant_v4f64(double* %p) nounwind {
330 ; SSE-LABEL: load_fdiv_op0_constant_v4f64:
332 ; SSE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
333 ; SSE-NEXT: divsd (%rdi), %xmm0
336 ; AVX-LABEL: load_fdiv_op0_constant_v4f64:
338 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
339 ; AVX-NEXT: vdivsd (%rdi), %xmm0, %xmm0
341 %x = load double, double* %p
342 %v = insertelement <4 x double> undef, double %x, i32 0
343 %b = fdiv <4 x double> <double 42.0, double undef, double undef, double undef>, %v
347 define <2 x double> @fadd_splat_splat_v2f64(<2 x double> %vx, <2 x double> %vy) {
348 ; SSE-LABEL: fadd_splat_splat_v2f64:
350 ; SSE-NEXT: addsd %xmm1, %xmm0
351 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
354 ; AVX-LABEL: fadd_splat_splat_v2f64:
356 ; AVX-NEXT: vaddsd %xmm1, %xmm0, %xmm0
357 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
359 %splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> zeroinitializer
360 %splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> zeroinitializer
361 %r = fadd <2 x double> %splatx, %splaty
365 define <4 x double> @fsub_splat_splat_v4f64(double %x, double %y) {
366 ; SSE-LABEL: fsub_splat_splat_v4f64:
368 ; SSE-NEXT: subsd %xmm1, %xmm0
369 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
370 ; SSE-NEXT: movapd %xmm0, %xmm1
373 ; AVX-LABEL: fsub_splat_splat_v4f64:
375 ; AVX-NEXT: vsubsd %xmm1, %xmm0, %xmm0
376 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
377 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
379 %vx = insertelement <4 x double> undef, double %x, i32 0
380 %vy = insertelement <4 x double> undef, double %y, i32 0
381 %splatx = shufflevector <4 x double> %vx, <4 x double> undef, <4 x i32> zeroinitializer
382 %splaty = shufflevector <4 x double> %vy, <4 x double> undef, <4 x i32> zeroinitializer
383 %r = fsub <4 x double> %splatx, %splaty
387 define <4 x float> @fmul_splat_splat_v4f32(<4 x float> %vx, <4 x float> %vy) {
388 ; SSE-LABEL: fmul_splat_splat_v4f32:
390 ; SSE-NEXT: mulss %xmm1, %xmm0
391 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
394 ; AVX-LABEL: fmul_splat_splat_v4f32:
396 ; AVX-NEXT: vmulss %xmm1, %xmm0, %xmm0
397 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
399 %splatx = shufflevector <4 x float> %vx, <4 x float> undef, <4 x i32> zeroinitializer
400 %splaty = shufflevector <4 x float> %vy, <4 x float> undef, <4 x i32> zeroinitializer
401 %r = fmul fast <4 x float> %splatx, %splaty
405 define <8 x float> @fdiv_splat_splat_v8f32(<8 x float> %vx, <8 x float> %vy) {
406 ; SSE-LABEL: fdiv_splat_splat_v8f32:
408 ; SSE-NEXT: divss %xmm2, %xmm0
409 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
410 ; SSE-NEXT: movaps %xmm0, %xmm1
413 ; AVX-LABEL: fdiv_splat_splat_v8f32:
415 ; AVX-NEXT: vdivss %xmm1, %xmm0, %xmm0
416 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
417 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
419 %splatx = shufflevector <8 x float> %vx, <8 x float> undef, <8 x i32> zeroinitializer
420 %splaty = shufflevector <8 x float> %vy, <8 x float> undef, <8 x i32> zeroinitializer
421 %r = fdiv fast <8 x float> %splatx, %splaty
425 ; Negative test - splat of non-zero indexes (still sink the splat).
427 define <2 x double> @fadd_splat_splat_nonzero_v2f64(<2 x double> %vx, <2 x double> %vy) {
428 ; SSE-LABEL: fadd_splat_splat_nonzero_v2f64:
430 ; SSE-NEXT: addpd %xmm1, %xmm0
431 ; SSE-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1,1]
434 ; AVX-LABEL: fadd_splat_splat_nonzero_v2f64:
436 ; AVX-NEXT: vaddpd %xmm1, %xmm0, %xmm0
437 ; AVX-NEXT: vpermilpd {{.*#+}} xmm0 = xmm0[1,1]
439 %splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> <i32 1, i32 1>
440 %splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> <i32 1, i32 1>
441 %r = fadd <2 x double> %splatx, %splaty
445 ; Negative test - splat of non-zero index and mismatched indexes.
447 define <2 x double> @fadd_splat_splat_mismatch_v2f64(<2 x double> %vx, <2 x double> %vy) {
448 ; SSE-LABEL: fadd_splat_splat_mismatch_v2f64:
450 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
451 ; SSE-NEXT: unpckhpd {{.*#+}} xmm1 = xmm1[1,1]
452 ; SSE-NEXT: addpd %xmm1, %xmm0
455 ; AVX-LABEL: fadd_splat_splat_mismatch_v2f64:
457 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
458 ; AVX-NEXT: vpermilpd {{.*#+}} xmm1 = xmm1[1,1]
459 ; AVX-NEXT: vaddpd %xmm1, %xmm0, %xmm0
461 %splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> <i32 0, i32 0>
462 %splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> <i32 1, i32 1>
463 %r = fadd <2 x double> %splatx, %splaty
467 ; Negative test - non-splat.
469 define <2 x double> @fadd_splat_nonsplat_v2f64(<2 x double> %vx, <2 x double> %vy) {
470 ; SSE-LABEL: fadd_splat_nonsplat_v2f64:
472 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
473 ; SSE-NEXT: addpd %xmm1, %xmm0
476 ; AVX-LABEL: fadd_splat_nonsplat_v2f64:
478 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
479 ; AVX-NEXT: vaddpd %xmm1, %xmm0, %xmm0
481 %splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> <i32 0, i32 0>
482 %splaty = shufflevector <2 x double> %vy, <2 x double> undef, <2 x i32> <i32 0, i32 1>
483 %r = fadd <2 x double> %splatx, %splaty
487 ; Negative test - non-FP.
489 define <2 x i64> @add_splat_splat_v2i64(<2 x i64> %vx, <2 x i64> %vy) {
490 ; SSE-LABEL: add_splat_splat_v2i64:
492 ; SSE-NEXT: paddq %xmm1, %xmm0
493 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
496 ; AVX-LABEL: add_splat_splat_v2i64:
498 ; AVX-NEXT: vpaddq %xmm1, %xmm0, %xmm0
499 ; AVX-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,1,0,1]
501 %splatx = shufflevector <2 x i64> %vx, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
502 %splaty = shufflevector <2 x i64> %vy, <2 x i64> undef, <2 x i32> <i32 0, i32 0>
503 %r = add <2 x i64> %splatx, %splaty
507 define <2 x double> @fadd_splat_const_op1_v2f64(<2 x double> %vx) {
508 ; SSE-LABEL: fadd_splat_const_op1_v2f64:
510 ; SSE-NEXT: addsd {{.*}}(%rip), %xmm0
511 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
514 ; AVX-LABEL: fadd_splat_const_op1_v2f64:
516 ; AVX-NEXT: vaddsd {{.*}}(%rip), %xmm0, %xmm0
517 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
519 %splatx = shufflevector <2 x double> %vx, <2 x double> undef, <2 x i32> zeroinitializer
520 %r = fadd <2 x double> %splatx, <double 42.0, double 42.0>
524 define <4 x double> @fsub_const_op0_splat_v4f64(double %x) {
525 ; SSE-LABEL: fsub_const_op0_splat_v4f64:
527 ; SSE-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
528 ; SSE-NEXT: subsd %xmm0, %xmm1
529 ; SSE-NEXT: unpcklpd {{.*#+}} xmm1 = xmm1[0,0]
530 ; SSE-NEXT: movapd %xmm1, %xmm0
533 ; AVX-LABEL: fsub_const_op0_splat_v4f64:
535 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
536 ; AVX-NEXT: vsubsd %xmm0, %xmm1, %xmm0
537 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
538 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
540 %vx = insertelement <4 x double> undef, double 8.0, i32 0
541 %vy = insertelement <4 x double> undef, double %x, i32 0
542 %splatx = shufflevector <4 x double> %vx, <4 x double> undef, <4 x i32> zeroinitializer
543 %splaty = shufflevector <4 x double> %vy, <4 x double> undef, <4 x i32> zeroinitializer
544 %r = fsub <4 x double> %splatx, %splaty
548 define <4 x float> @fmul_splat_const_op1_v4f32(<4 x float> %vx, <4 x float> %vy) {
549 ; SSE-LABEL: fmul_splat_const_op1_v4f32:
551 ; SSE-NEXT: mulss {{.*}}(%rip), %xmm0
552 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
555 ; AVX-LABEL: fmul_splat_const_op1_v4f32:
557 ; AVX-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
558 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
560 %splatx = shufflevector <4 x float> %vx, <4 x float> undef, <4 x i32> zeroinitializer
561 %r = fmul fast <4 x float> %splatx, <float 17.0, float 17.0, float 17.0, float 17.0>
565 define <8 x float> @fdiv_splat_const_op0_v8f32(<8 x float> %vy) {
566 ; SSE-LABEL: fdiv_splat_const_op0_v8f32:
568 ; SSE-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
569 ; SSE-NEXT: divss %xmm0, %xmm1
570 ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
571 ; SSE-NEXT: movaps %xmm1, %xmm0
574 ; AVX-LABEL: fdiv_splat_const_op0_v8f32:
576 ; AVX-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
577 ; AVX-NEXT: vdivss %xmm0, %xmm1, %xmm0
578 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
579 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
581 %splatx = shufflevector <8 x float> <float 4.5, float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0>, <8 x float> undef, <8 x i32> zeroinitializer
582 %splaty = shufflevector <8 x float> %vy, <8 x float> undef, <8 x i32> zeroinitializer
583 %r = fdiv fast <8 x float> %splatx, %splaty
587 define <8 x float> @fdiv_const_op1_splat_v8f32(<8 x float> %vx) {
588 ; SSE-LABEL: fdiv_const_op1_splat_v8f32:
590 ; SSE-NEXT: xorps %xmm1, %xmm1
591 ; SSE-NEXT: divss %xmm1, %xmm0
592 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
593 ; SSE-NEXT: movaps %xmm0, %xmm1
596 ; AVX-LABEL: fdiv_const_op1_splat_v8f32:
598 ; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
599 ; AVX-NEXT: vdivss %xmm1, %xmm0, %xmm0
600 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
601 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
603 %splatx = shufflevector <8 x float> %vx, <8 x float> undef, <8 x i32> zeroinitializer
604 %splaty = shufflevector <8 x float> <float 0.0, float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0>, <8 x float> undef, <8 x i32> zeroinitializer
605 %r = fdiv fast <8 x float> %splatx, %splaty
609 define <2 x double> @splat0_fadd_v2f64(<2 x double> %vx, <2 x double> %vy) {
610 ; SSE-LABEL: splat0_fadd_v2f64:
612 ; SSE-NEXT: addsd %xmm1, %xmm0
613 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
616 ; AVX-LABEL: splat0_fadd_v2f64:
618 ; AVX-NEXT: vaddsd %xmm1, %xmm0, %xmm0
619 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
621 %b = fadd <2 x double> %vx, %vy
622 %r = shufflevector <2 x double> %b, <2 x double> undef, <2 x i32> zeroinitializer
626 define <4 x double> @splat0_fsub_v4f64(double %x, double %y) {
627 ; SSE-LABEL: splat0_fsub_v4f64:
629 ; SSE-NEXT: subsd %xmm1, %xmm0
630 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
631 ; SSE-NEXT: movapd %xmm0, %xmm1
634 ; AVX-LABEL: splat0_fsub_v4f64:
636 ; AVX-NEXT: vsubsd %xmm1, %xmm0, %xmm0
637 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
638 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
640 %vx = insertelement <4 x double> undef, double %x, i32 0
641 %vy = insertelement <4 x double> undef, double %y, i32 0
642 %b = fsub <4 x double> %vx, %vy
643 %r = shufflevector <4 x double> %b, <4 x double> undef, <4 x i32> zeroinitializer
647 define <4 x float> @splat0_fmul_v4f32(<4 x float> %vx, <4 x float> %vy) {
648 ; SSE-LABEL: splat0_fmul_v4f32:
650 ; SSE-NEXT: mulss %xmm1, %xmm0
651 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
654 ; AVX-LABEL: splat0_fmul_v4f32:
656 ; AVX-NEXT: vmulss %xmm1, %xmm0, %xmm0
657 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
659 %b = fmul fast <4 x float> %vx, %vy
660 %r = shufflevector <4 x float> %b, <4 x float> undef, <4 x i32> zeroinitializer
664 define <8 x float> @splat0_fdiv_v8f32(<8 x float> %vx, <8 x float> %vy) {
665 ; SSE-LABEL: splat0_fdiv_v8f32:
667 ; SSE-NEXT: divss %xmm2, %xmm0
668 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
669 ; SSE-NEXT: movaps %xmm0, %xmm1
672 ; AVX-LABEL: splat0_fdiv_v8f32:
674 ; AVX-NEXT: vdivss %xmm1, %xmm0, %xmm0
675 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
676 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
678 %b = fdiv fast <8 x float> %vx, %vy
679 %r = shufflevector <8 x float> %b, <8 x float> undef, <8 x i32> zeroinitializer
683 define <2 x double> @splat0_fadd_const_op1_v2f64(<2 x double> %vx) {
684 ; SSE-LABEL: splat0_fadd_const_op1_v2f64:
686 ; SSE-NEXT: addsd {{.*}}(%rip), %xmm0
687 ; SSE-NEXT: unpcklpd {{.*#+}} xmm0 = xmm0[0,0]
690 ; AVX-LABEL: splat0_fadd_const_op1_v2f64:
692 ; AVX-NEXT: vaddsd {{.*}}(%rip), %xmm0, %xmm0
693 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
695 %b = fadd <2 x double> %vx, <double 42.0, double 12.0>
696 %r = shufflevector <2 x double> %b, <2 x double> undef, <2 x i32> zeroinitializer
700 define <4 x double> @splat0_fsub_const_op0_v4f64(double %x) {
701 ; SSE-LABEL: splat0_fsub_const_op0_v4f64:
703 ; SSE-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
704 ; SSE-NEXT: subsd %xmm0, %xmm1
705 ; SSE-NEXT: unpcklpd {{.*#+}} xmm1 = xmm1[0,0]
706 ; SSE-NEXT: movapd %xmm1, %xmm0
709 ; AVX-LABEL: splat0_fsub_const_op0_v4f64:
711 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero
712 ; AVX-NEXT: vsubsd %xmm0, %xmm1, %xmm0
713 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
714 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
716 %vx = insertelement <4 x double> undef, double %x, i32 0
717 %b = fsub <4 x double> <double -42.0, double 42.0, double 0.0, double 1.0>, %vx
718 %r = shufflevector <4 x double> %b, <4 x double> undef, <4 x i32> zeroinitializer
722 define <4 x float> @splat0_fmul_const_op1_v4f32(<4 x float> %vx) {
723 ; SSE-LABEL: splat0_fmul_const_op1_v4f32:
725 ; SSE-NEXT: mulss {{.*}}(%rip), %xmm0
726 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
729 ; AVX-LABEL: splat0_fmul_const_op1_v4f32:
731 ; AVX-NEXT: vmulss {{.*}}(%rip), %xmm0, %xmm0
732 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
734 %b = fmul fast <4 x float> %vx, <float 6.0, float -1.0, float 1.0, float 7.0>
735 %r = shufflevector <4 x float> %b, <4 x float> undef, <4 x i32> zeroinitializer
739 define <8 x float> @splat0_fdiv_const_op1_v8f32(<8 x float> %vx) {
740 ; SSE-LABEL: splat0_fdiv_const_op1_v8f32:
742 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,0,0,0]
743 ; SSE-NEXT: movaps %xmm0, %xmm1
746 ; AVX-LABEL: splat0_fdiv_const_op1_v8f32:
748 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
749 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
751 %b = fdiv fast <8 x float> %vx, <float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0, float 8.0>
752 %r = shufflevector <8 x float> %b, <8 x float> undef, <8 x i32> zeroinitializer
756 define <8 x float> @splat0_fdiv_const_op0_v8f32(<8 x float> %vx) {
757 ; SSE-LABEL: splat0_fdiv_const_op0_v8f32:
759 ; SSE-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
760 ; SSE-NEXT: divss %xmm0, %xmm1
761 ; SSE-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,0,0,0]
762 ; SSE-NEXT: movaps %xmm1, %xmm0
765 ; AVX-LABEL: splat0_fdiv_const_op0_v8f32:
767 ; AVX-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
768 ; AVX-NEXT: vdivss %xmm0, %xmm1, %xmm0
769 ; AVX-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,0,0]
770 ; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
772 %b = fdiv fast <8 x float> <float 1.0, float 2.0, float 3.0, float 4.0, float 5.0, float 6.0, float 7.0, float 8.0>, %vx
773 %r = shufflevector <8 x float> %b, <8 x float> undef, <8 x i32> zeroinitializer
777 define <4 x float> @multi_use_binop(<4 x float> %x, <4 x float> %y) {
778 ; SSE-LABEL: multi_use_binop:
780 ; SSE-NEXT: mulps %xmm1, %xmm0
781 ; SSE-NEXT: movlhps {{.*#+}} xmm1 = xmm1[0],xmm0[0]
782 ; SSE-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,1,2,0]
783 ; SSE-NEXT: addps %xmm1, %xmm0
786 ; AVX-LABEL: multi_use_binop:
788 ; AVX-NEXT: vmulps %xmm1, %xmm0, %xmm0
789 ; AVX-NEXT: vpermilps {{.*#+}} xmm1 = xmm0[0,1,2,0]
790 ; AVX-NEXT: vmovddup {{.*#+}} xmm0 = xmm0[0,0]
791 ; AVX-NEXT: vaddps %xmm0, %xmm1, %xmm0
793 %mul = fmul <4 x float> %x, %y
794 %mul0 = shufflevector <4 x float> %mul, <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 undef, i32 0>
795 %mul1 = shufflevector <4 x float> %mul, <4 x float> undef, <4 x i32> <i32 undef, i32 undef, i32 undef, i32 1>
796 %r = fadd <4 x float> %mul0, %mul1