1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX2,AVX2-SLOW
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2,+fast-variable-crosslane-shuffle,+fast-variable-perlane-shuffle | FileCheck %s --check-prefixes=AVX2,AVX2-FAST-ALL
4 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2,+fast-variable-perlane-shuffle | FileCheck %s --check-prefixes=AVX2,AVX2-FAST-PERLANE
7 define <2 x double> @foo2(<2 x double> %v, ptr%p) nounwind {
10 ; AVX2-NEXT: vshufpd {{.*#+}} xmm0 = xmm0[1,1]
11 ; AVX2-NEXT: vmovapd %xmm0, (%rdi)
13 %res = shufflevector <2 x double> %v, <2 x double> undef, <2 x i32> <i32 1, i32 1>
14 %res1 = shufflevector<2 x double> %res, <2 x double> undef, <2 x i32> <i32 1, i32 undef>
15 store <2 x double> %res, ptr %p
16 ret <2 x double> %res1
19 define <4 x double> @foo4(<4 x double> %v, ptr%p) nounwind {
22 ; AVX2-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2]
23 ; AVX2-NEXT: vmovaps %ymm0, (%rdi)
25 %res = shufflevector <4 x double> %v, <4 x double> undef, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
26 %res1 = shufflevector<4 x double> %res, <4 x double> undef, <4 x i32> <i32 2, i32 0, i32 undef, i32 undef>
27 store <4 x double> %res, ptr %p
28 ret <4 x double> %res1
31 define <8 x float> @foo8(<8 x float> %v, ptr%p) nounwind {
32 ; AVX2-SLOW-LABEL: foo8:
34 ; AVX2-SLOW-NEXT: vmovshdup {{.*#+}} ymm0 = ymm0[1,1,3,3,5,5,7,7]
35 ; AVX2-SLOW-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2]
36 ; AVX2-SLOW-NEXT: vmovaps %ymm0, (%rdi)
37 ; AVX2-SLOW-NEXT: retq
39 ; AVX2-FAST-ALL-LABEL: foo8:
40 ; AVX2-FAST-ALL: # %bb.0:
41 ; AVX2-FAST-ALL-NEXT: vbroadcastss {{.*#+}} ymm1 = [5,5,5,5,5,5,5,5]
42 ; AVX2-FAST-ALL-NEXT: vpermps %ymm0, %ymm1, %ymm0
43 ; AVX2-FAST-ALL-NEXT: vmovaps %ymm0, (%rdi)
44 ; AVX2-FAST-ALL-NEXT: retq
46 ; AVX2-FAST-PERLANE-LABEL: foo8:
47 ; AVX2-FAST-PERLANE: # %bb.0:
48 ; AVX2-FAST-PERLANE-NEXT: vmovshdup {{.*#+}} ymm0 = ymm0[1,1,3,3,5,5,7,7]
49 ; AVX2-FAST-PERLANE-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2]
50 ; AVX2-FAST-PERLANE-NEXT: vmovaps %ymm0, (%rdi)
51 ; AVX2-FAST-PERLANE-NEXT: retq
52 %res = shufflevector <8 x float> %v, <8 x float> undef, <8 x i32> <i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5>
53 %res1 = shufflevector<8 x float> %res, <8 x float> undef, <8 x i32> <i32 2, i32 0, i32 undef, i32 undef, i32 5, i32 1, i32 3, i32 7>
54 store <8 x float> %res, ptr %p
58 define <4 x i32> @undef_splatmask(<4 x i32> %v) nounwind {
59 ; AVX2-LABEL: undef_splatmask:
61 ; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,2,3,3]
63 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef>
64 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
68 define <4 x i32> @undef_splatmask2(<4 x i32> %v) nounwind {
69 ; AVX2-LABEL: undef_splatmask2:
71 ; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,2,3,3]
73 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 2, i32 undef>
74 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
78 define <4 x i32> @undef_splatmask3(<4 x i32> %v) nounwind {
79 ; AVX2-LABEL: undef_splatmask3:
81 ; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,2,3,3]
83 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef>
84 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 3>
88 define <4 x i32> @undef_splatmask4(<4 x i32> %v, ptr %p) nounwind {
89 ; AVX2-LABEL: undef_splatmask4:
91 ; AVX2-NEXT: vshufps {{.*#+}} xmm1 = xmm0[2,2,3,3]
92 ; AVX2-NEXT: vshufps {{.*#+}} xmm0 = xmm0[2,3,2,3]
93 ; AVX2-NEXT: vmovaps %xmm0, (%rdi)
94 ; AVX2-NEXT: vmovaps %xmm1, %xmm0
96 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef>
97 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
98 store <4 x i32> %res, ptr %p
102 define <4 x i32> @undef_splatmask5(<4 x i32> %v, ptr %p) nounwind {
103 ; AVX2-LABEL: undef_splatmask5:
105 ; AVX2-NEXT: vbroadcastss %xmm0, %xmm0
106 ; AVX2-NEXT: vmovaps %xmm0, (%rdi)
108 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 0, i32 undef>
109 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 3>
110 store <4 x i32> %res, ptr %p