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-shuffle | FileCheck %s --check-prefixes=AVX2,AVX2-FAST
6 define <2 x double> @foo2(<2 x double> %v, <2 x double> *%p) nounwind {
9 ; AVX2-NEXT: vpermilpd {{.*#+}} xmm0 = xmm0[1,1]
10 ; AVX2-NEXT: vmovapd %xmm0, (%rdi)
12 %res = shufflevector <2 x double> %v, <2 x double> undef, <2 x i32> <i32 1, i32 1>
13 %res1 = shufflevector<2 x double> %res, <2 x double> undef, <2 x i32> <i32 1, i32 undef>
14 store <2 x double> %res, <2 x double>* %p
15 ret <2 x double> %res1
18 define <4 x double> @foo4(<4 x double> %v, <4 x double> *%p) nounwind {
21 ; AVX2-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2]
22 ; AVX2-NEXT: vmovaps %ymm0, (%rdi)
24 %res = shufflevector <4 x double> %v, <4 x double> undef, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
25 %res1 = shufflevector<4 x double> %res, <4 x double> undef, <4 x i32> <i32 2, i32 0, i32 undef, i32 undef>
26 store <4 x double> %res, <4 x double>* %p
27 ret <4 x double> %res1
30 define <8 x float> @foo8(<8 x float> %v, <8 x float> *%p) nounwind {
31 ; AVX2-SLOW-LABEL: foo8:
33 ; AVX2-SLOW-NEXT: vmovshdup {{.*#+}} ymm0 = ymm0[1,1,3,3,5,5,7,7]
34 ; AVX2-SLOW-NEXT: vpermpd {{.*#+}} ymm0 = ymm0[2,2,2,2]
35 ; AVX2-SLOW-NEXT: vmovaps %ymm0, (%rdi)
36 ; AVX2-SLOW-NEXT: retq
38 ; AVX2-FAST-LABEL: foo8:
40 ; AVX2-FAST-NEXT: vbroadcastss {{.*#+}} ymm1 = [5,5,5,5,5,5,5,5]
41 ; AVX2-FAST-NEXT: vpermps %ymm0, %ymm1, %ymm0
42 ; AVX2-FAST-NEXT: vmovaps %ymm0, (%rdi)
43 ; AVX2-FAST-NEXT: retq
44 %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>
45 %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>
46 store <8 x float> %res, <8 x float>* %p
50 define <4 x i32> @undef_splatmask(<4 x i32> %v) nounwind {
51 ; AVX2-LABEL: undef_splatmask:
53 ; AVX2-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
55 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef>
56 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
60 define <4 x i32> @undef_splatmask2(<4 x i32> %v) nounwind {
61 ; AVX2-LABEL: undef_splatmask2:
63 ; AVX2-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
65 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 1, i32 2, i32 undef>
66 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
70 define <4 x i32> @undef_splatmask3(<4 x i32> %v) nounwind {
71 ; AVX2-LABEL: undef_splatmask3:
73 ; AVX2-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
75 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef>
76 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 3>
80 define <4 x i32> @undef_splatmask4(<4 x i32> %v, <4 x i32>* %p) nounwind {
81 ; AVX2-LABEL: undef_splatmask4:
83 ; AVX2-NEXT: vpermilps {{.*#+}} xmm1 = xmm0[2,2,3,3]
84 ; AVX2-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,3,2,3]
85 ; AVX2-NEXT: vmovaps %xmm0, (%rdi)
86 ; AVX2-NEXT: vmovaps %xmm1, %xmm0
88 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 2, i32 undef, i32 2, i32 undef>
89 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef>
90 store <4 x i32> %res, <4 x i32>* %p
94 define <4 x i32> @undef_splatmask5(<4 x i32> %v, <4 x i32>* %p) nounwind {
95 ; AVX2-LABEL: undef_splatmask5:
97 ; AVX2-NEXT: vbroadcastss %xmm0, %xmm0
98 ; AVX2-NEXT: vmovaps %xmm0, (%rdi)
100 %res = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 0, i32 undef>
101 %res1 = shufflevector <4 x i32> %res, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 3>
102 store <4 x i32> %res, <4 x i32>* %p