1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE,SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3 | FileCheck %s --check-prefixes=SSE,SSSE3,SSSE3-SLOW
4 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3,fast-hops | FileCheck %s --check-prefixes=SSE,SSSE3,SSSE3-FAST
5 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX,AVX1,AVX1-SLOW
6 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx,fast-hops | FileCheck %s --check-prefixes=AVX,AVX1,AVX1-FAST
7 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX,AVX2
9 define float @pr26491(<4 x float> %a0) {
10 ; SSE2-LABEL: pr26491:
12 ; SSE2-NEXT: movaps %xmm0, %xmm1
13 ; SSE2-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,1],xmm0[3,3]
14 ; SSE2-NEXT: addps %xmm0, %xmm1
15 ; SSE2-NEXT: movaps %xmm1, %xmm0
16 ; SSE2-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
17 ; SSE2-NEXT: addss %xmm1, %xmm0
20 ; SSSE3-LABEL: pr26491:
22 ; SSSE3-NEXT: movshdup {{.*#+}} xmm1 = xmm0[1,1,3,3]
23 ; SSSE3-NEXT: addps %xmm0, %xmm1
24 ; SSSE3-NEXT: movaps %xmm1, %xmm0
25 ; SSSE3-NEXT: unpckhpd {{.*#+}} xmm0 = xmm0[1],xmm1[1]
26 ; SSSE3-NEXT: addss %xmm1, %xmm0
31 ; AVX-NEXT: vmovshdup {{.*#+}} xmm1 = xmm0[1,1,3,3]
32 ; AVX-NEXT: vaddps %xmm0, %xmm1, %xmm0
33 ; AVX-NEXT: vpermilpd {{.*#+}} xmm1 = xmm0[1,0]
34 ; AVX-NEXT: vaddss %xmm0, %xmm1, %xmm0
36 %1 = shufflevector <4 x float> %a0, <4 x float> undef, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
37 %2 = fadd <4 x float> %1, %a0
38 %3 = extractelement <4 x float> %2, i32 2
39 %4 = extractelement <4 x float> %2, i32 0
40 %5 = fadd float %3, %4
44 ; When simplifying away a splat (broadcast), the hop type must match the shuffle type.
46 define <4 x double> @PR41414(i64 %x, <4 x double> %y) {
47 ; SSE2-LABEL: PR41414:
49 ; SSE2-NEXT: movq %rdi, %xmm2
50 ; SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
51 ; SSE2-NEXT: subpd {{.*}}(%rip), %xmm2
52 ; SSE2-NEXT: movapd %xmm2, %xmm3
53 ; SSE2-NEXT: unpckhpd {{.*#+}} xmm3 = xmm3[1],xmm2[1]
54 ; SSE2-NEXT: addpd %xmm2, %xmm3
55 ; SSE2-NEXT: unpcklpd {{.*#+}} xmm3 = xmm3[0,0]
56 ; SSE2-NEXT: divpd %xmm3, %xmm1
57 ; SSE2-NEXT: divpd %xmm3, %xmm0
58 ; SSE2-NEXT: xorpd %xmm2, %xmm2
59 ; SSE2-NEXT: addpd %xmm2, %xmm0
60 ; SSE2-NEXT: addpd %xmm2, %xmm1
63 ; SSSE3-SLOW-LABEL: PR41414:
64 ; SSSE3-SLOW: # %bb.0:
65 ; SSSE3-SLOW-NEXT: movq %rdi, %xmm2
66 ; SSSE3-SLOW-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
67 ; SSSE3-SLOW-NEXT: subpd {{.*}}(%rip), %xmm2
68 ; SSSE3-SLOW-NEXT: movapd %xmm2, %xmm3
69 ; SSSE3-SLOW-NEXT: unpckhpd {{.*#+}} xmm3 = xmm3[1],xmm2[1]
70 ; SSSE3-SLOW-NEXT: addpd %xmm2, %xmm3
71 ; SSSE3-SLOW-NEXT: movddup {{.*#+}} xmm2 = xmm3[0,0]
72 ; SSSE3-SLOW-NEXT: divpd %xmm2, %xmm1
73 ; SSSE3-SLOW-NEXT: divpd %xmm2, %xmm0
74 ; SSSE3-SLOW-NEXT: xorpd %xmm2, %xmm2
75 ; SSSE3-SLOW-NEXT: addpd %xmm2, %xmm0
76 ; SSSE3-SLOW-NEXT: addpd %xmm2, %xmm1
77 ; SSSE3-SLOW-NEXT: retq
79 ; SSSE3-FAST-LABEL: PR41414:
80 ; SSSE3-FAST: # %bb.0:
81 ; SSSE3-FAST-NEXT: movq %rdi, %xmm2
82 ; SSSE3-FAST-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
83 ; SSSE3-FAST-NEXT: subpd {{.*}}(%rip), %xmm2
84 ; SSSE3-FAST-NEXT: haddpd %xmm2, %xmm2
85 ; SSSE3-FAST-NEXT: divpd %xmm2, %xmm1
86 ; SSSE3-FAST-NEXT: divpd %xmm2, %xmm0
87 ; SSSE3-FAST-NEXT: xorpd %xmm2, %xmm2
88 ; SSSE3-FAST-NEXT: addpd %xmm2, %xmm0
89 ; SSSE3-FAST-NEXT: addpd %xmm2, %xmm1
90 ; SSSE3-FAST-NEXT: retq
92 ; AVX1-SLOW-LABEL: PR41414:
94 ; AVX1-SLOW-NEXT: vmovq %rdi, %xmm1
95 ; AVX1-SLOW-NEXT: vpunpckldq {{.*#+}} xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
96 ; AVX1-SLOW-NEXT: vsubpd {{.*}}(%rip), %xmm1, %xmm1
97 ; AVX1-SLOW-NEXT: vpermilpd {{.*#+}} xmm2 = xmm1[1,0]
98 ; AVX1-SLOW-NEXT: vaddpd %xmm1, %xmm2, %xmm1
99 ; AVX1-SLOW-NEXT: vmovddup {{.*#+}} xmm1 = xmm1[0,0]
100 ; AVX1-SLOW-NEXT: vinsertf128 $1, %xmm1, %ymm1, %ymm1
101 ; AVX1-SLOW-NEXT: vdivpd %ymm1, %ymm0, %ymm0
102 ; AVX1-SLOW-NEXT: vxorpd %xmm1, %xmm1, %xmm1
103 ; AVX1-SLOW-NEXT: vaddpd %ymm1, %ymm0, %ymm0
104 ; AVX1-SLOW-NEXT: retq
106 ; AVX1-FAST-LABEL: PR41414:
107 ; AVX1-FAST: # %bb.0:
108 ; AVX1-FAST-NEXT: vmovq %rdi, %xmm1
109 ; AVX1-FAST-NEXT: vpunpckldq {{.*#+}} xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
110 ; AVX1-FAST-NEXT: vsubpd {{.*}}(%rip), %xmm1, %xmm1
111 ; AVX1-FAST-NEXT: vhaddpd %xmm1, %xmm1, %xmm1
112 ; AVX1-FAST-NEXT: vinsertf128 $1, %xmm1, %ymm1, %ymm1
113 ; AVX1-FAST-NEXT: vdivpd %ymm1, %ymm0, %ymm0
114 ; AVX1-FAST-NEXT: vxorpd %xmm1, %xmm1, %xmm1
115 ; AVX1-FAST-NEXT: vaddpd %ymm1, %ymm0, %ymm0
116 ; AVX1-FAST-NEXT: retq
118 ; AVX2-LABEL: PR41414:
120 ; AVX2-NEXT: vmovq %rdi, %xmm1
121 ; AVX2-NEXT: vpunpckldq {{.*#+}} xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
122 ; AVX2-NEXT: vsubpd {{.*}}(%rip), %xmm1, %xmm1
123 ; AVX2-NEXT: vpermilpd {{.*#+}} xmm2 = xmm1[1,0]
124 ; AVX2-NEXT: vaddsd %xmm1, %xmm2, %xmm1
125 ; AVX2-NEXT: vbroadcastsd %xmm1, %ymm1
126 ; AVX2-NEXT: vdivpd %ymm1, %ymm0, %ymm0
127 ; AVX2-NEXT: vxorpd %xmm1, %xmm1, %xmm1
128 ; AVX2-NEXT: vaddpd %ymm1, %ymm0, %ymm0
130 %conv = uitofp i64 %x to double
131 %t0 = insertelement <4 x double> undef, double %conv, i32 0
132 %t1 = shufflevector <4 x double> %t0, <4 x double> undef, <4 x i32> zeroinitializer
133 %t2 = fdiv <4 x double> %y, %t1
134 %t3 = fadd <4 x double> zeroinitializer, %t2