[TTI] getTypeBasedIntrinsicInstrCost - add basic handling for strided load/store...
[llvm-project.git] / llvm / test / CodeGen / X86 / vector-shuffle-512-v16.ll
blobb1efb416014b0eab385789027df64574370bd656
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx512f,+avx512dq | FileCheck %s --check-prefixes=ALL,SLOW,AVX512F
3 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx512bw,+avx512dq | FileCheck %s --check-prefixes=ALL,SLOW,AVX512BW
4 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx512f,+avx512dq,+fast-variable-crosslane-shuffle,+fast-variable-perlane-shuffle | FileCheck %s --check-prefixes=ALL,FAST,AVX512F
5 ; RUN: llc < %s -mcpu=x86-64 -mattr=+avx512bw,+avx512dq,+fast-variable-crosslane-shuffle,+fast-variable-perlane-shuffle | FileCheck %s --check-prefixes=ALL,FAST,AVX512BW
7 target triple = "x86_64-unknown-unknown"
9 define <16 x float> @shuffle_v16f32_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00(<16 x float> %a, <16 x float> %b) {
10 ; ALL-LABEL: shuffle_v16f32_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00:
11 ; ALL:       # %bb.0:
12 ; ALL-NEXT:    vbroadcastss %xmm0, %zmm0
13 ; ALL-NEXT:    retq
14   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32><i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
15   ret <16 x float> %shuffle
18 define <16 x float> @shuffle_v16f32_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08(<16 x float> %a, <16 x float> %b) {
19 ; SLOW-LABEL: shuffle_v16f32_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08:
20 ; SLOW:       # %bb.0:
21 ; SLOW-NEXT:    vextractf32x4 $2, %zmm0, %xmm0
22 ; SLOW-NEXT:    vbroadcastss %xmm0, %zmm0
23 ; SLOW-NEXT:    retq
25 ; FAST-LABEL: shuffle_v16f32_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08:
26 ; FAST:       # %bb.0:
27 ; FAST-NEXT:    vbroadcastss {{.*#+}} zmm1 = [8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8]
28 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
29 ; FAST-NEXT:    retq
30   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32><i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
31   ret <16 x float> %shuffle
34 define <16 x float> @shuffle_v16f32_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_bc(<16 x i32> %a, <16 x i32> %b) {
35 ; SLOW-LABEL: shuffle_v16f32_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_bc:
36 ; SLOW:       # %bb.0:
37 ; SLOW-NEXT:    vextractf32x4 $2, %zmm0, %xmm0
38 ; SLOW-NEXT:    vbroadcastss %xmm0, %zmm0
39 ; SLOW-NEXT:    retq
41 ; FAST-LABEL: shuffle_v16f32_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_08_bc:
42 ; FAST:       # %bb.0:
43 ; FAST-NEXT:    vbroadcastss {{.*#+}} zmm1 = [8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8]
44 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
45 ; FAST-NEXT:    retq
46   %tmp0 = bitcast <16 x i32> %a to <16 x float>
47   %tmp1 = bitcast <16 x i32> %b to <16 x float>
48   %shuffle = shufflevector <16 x float> %tmp0, <16 x float> %tmp1, <16 x i32><i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
49   ret <16 x float> %shuffle
52 define <16 x float> @shuffle_v16f32_00_10_01_11_04_14_05_15_08_18_09_19_0c_1c_0d_1d(<16 x float> %a, <16 x float> %b) {
53 ; ALL-LABEL: shuffle_v16f32_00_10_01_11_04_14_05_15_08_18_09_19_0c_1c_0d_1d:
54 ; ALL:       # %bb.0:
55 ; ALL-NEXT:    vunpcklps {{.*#+}} zmm0 = zmm0[0],zmm1[0],zmm0[1],zmm1[1],zmm0[4],zmm1[4],zmm0[5],zmm1[5],zmm0[8],zmm1[8],zmm0[9],zmm1[9],zmm0[12],zmm1[12],zmm0[13],zmm1[13]
56 ; ALL-NEXT:    retq
57   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32><i32 0, i32 16, i32 1, i32 17, i32 4, i32 20, i32 5, i32 21, i32 8, i32 24, i32 9, i32 25, i32 12, i32 28, i32 13, i32 29>
58   ret <16 x float> %shuffle
61 define <16 x float> @shuffle_v16f32_00_zz_01_zz_04_zz_05_zz_08_zz_09_zz_0c_zz_0d_zz(<16 x float> %a, <16 x float> %b) {
62 ; ALL-LABEL: shuffle_v16f32_00_zz_01_zz_04_zz_05_zz_08_zz_09_zz_0c_zz_0d_zz:
63 ; ALL:       # %bb.0:
64 ; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
65 ; ALL-NEXT:    vunpcklps {{.*#+}} zmm0 = zmm0[0],zmm1[0],zmm0[1],zmm1[1],zmm0[4],zmm1[4],zmm0[5],zmm1[5],zmm0[8],zmm1[8],zmm0[9],zmm1[9],zmm0[12],zmm1[12],zmm0[13],zmm1[13]
66 ; ALL-NEXT:    retq
67   %shuffle = shufflevector <16 x float> %a, <16 x float> zeroinitializer, <16 x i32><i32 0, i32 16, i32 1, i32 16, i32 4, i32 16, i32 5, i32 16, i32 8, i32 16, i32 9, i32 16, i32 12, i32 16, i32 13, i32 16>
68   ret <16 x float> %shuffle
71 define <16 x float> @shuffle_v16f32_vunpcklps_swap(<16 x float> %a, <16 x float> %b) {
72 ; ALL-LABEL: shuffle_v16f32_vunpcklps_swap:
73 ; ALL:       # %bb.0:
74 ; ALL-NEXT:    vunpcklps {{.*#+}} zmm0 = zmm1[0],zmm0[0],zmm1[1],zmm0[1],zmm1[4],zmm0[4],zmm1[5],zmm0[5],zmm1[8],zmm0[8],zmm1[9],zmm0[9],zmm1[12],zmm0[12],zmm1[13],zmm0[13]
75 ; ALL-NEXT:    retq
76   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 16, i32 0, i32 17, i32 1, i32 20, i32 4, i32 21, i32 5, i32 24, i32 8, i32 25, i32 9, i32 28, i32 12, i32 29, i32 13>
77   ret <16 x float> %shuffle
80 ; PR34382
81 define <16 x float> @shuffle_v16f32_01_01_03_00_06_04_05_07_08_08_09_09_15_14_14_12(<16 x float> %a0) {
82 ; ALL-LABEL: shuffle_v16f32_01_01_03_00_06_04_05_07_08_08_09_09_15_14_14_12:
83 ; ALL:       # %bb.0:
84 ; ALL-NEXT:    vpermilps {{.*#+}} zmm0 = zmm0[1,1,3,0,6,4,5,7,8,8,9,9,15,14,14,12]
85 ; ALL-NEXT:    retq
86   %shuffle = shufflevector <16 x float> %a0, <16 x float> poison, <16 x i32> <i32 1, i32 1, i32 3, i32 0, i32 6, i32 4, i32 5, i32 7, i32 8, i32 8, i32 9, i32 9, i32 15, i32 14, i32 14, i32 12>
87   ret <16 x float> %shuffle
90 define <16 x i32> @shuffle_v16i32_00_10_01_11_04_14_05_15_08_18_09_19_0c_1c_0d_1d(<16 x i32> %a, <16 x i32> %b) {
91 ; ALL-LABEL: shuffle_v16i32_00_10_01_11_04_14_05_15_08_18_09_19_0c_1c_0d_1d:
92 ; ALL:       # %bb.0:
93 ; ALL-NEXT:    vunpcklps {{.*#+}} zmm0 = zmm0[0],zmm1[0],zmm0[1],zmm1[1],zmm0[4],zmm1[4],zmm0[5],zmm1[5],zmm0[8],zmm1[8],zmm0[9],zmm1[9],zmm0[12],zmm1[12],zmm0[13],zmm1[13]
94 ; ALL-NEXT:    retq
95   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 0, i32 16, i32 1, i32 17, i32 4, i32 20, i32 5, i32 21, i32 8, i32 24, i32 9, i32 25, i32 12, i32 28, i32 13, i32 29>
96   ret <16 x i32> %shuffle
99 define <16 x i32> @shuffle_v16i32_zz_10_zz_11_zz_14_zz_15_zz_18_zz_19_zz_1c_zz_1d(<16 x i32> %a, <16 x i32> %b) {
100 ; ALL-LABEL: shuffle_v16i32_zz_10_zz_11_zz_14_zz_15_zz_18_zz_19_zz_1c_zz_1d:
101 ; ALL:       # %bb.0:
102 ; ALL-NEXT:    vxorps %xmm0, %xmm0, %xmm0
103 ; ALL-NEXT:    vunpcklps {{.*#+}} zmm0 = zmm0[0],zmm1[0],zmm0[1],zmm1[1],zmm0[4],zmm1[4],zmm0[5],zmm1[5],zmm0[8],zmm1[8],zmm0[9],zmm1[9],zmm0[12],zmm1[12],zmm0[13],zmm1[13]
104 ; ALL-NEXT:    retq
105   %shuffle = shufflevector <16 x i32> zeroinitializer, <16 x i32> %b, <16 x i32><i32 15, i32 16, i32 13, i32 17, i32 11, i32 20, i32 9, i32 21, i32 7, i32 24, i32 5, i32 25, i32 3, i32 28, i32 1, i32 29>
106   ret <16 x i32> %shuffle
109 define <16 x float> @shuffle_v16f32_02_12_03_13_06_16_07_17_0a_1a_0b_1b_0e_1e_0f_1f(<16 x float> %a, <16 x float> %b) {
110 ; ALL-LABEL: shuffle_v16f32_02_12_03_13_06_16_07_17_0a_1a_0b_1b_0e_1e_0f_1f:
111 ; ALL:       # %bb.0:
112 ; ALL-NEXT:    vunpckhps {{.*#+}} zmm0 = zmm0[2],zmm1[2],zmm0[3],zmm1[3],zmm0[6],zmm1[6],zmm0[7],zmm1[7],zmm0[10],zmm1[10],zmm0[11],zmm1[11],zmm0[14],zmm1[14],zmm0[15],zmm1[15]
113 ; ALL-NEXT:    retq
114   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32><i32 2, i32 18, i32 3, i32 19, i32 6, i32 22, i32 7, i32 23, i32 10, i32 26, i32 11, i32 27, i32 14, i32 30, i32 15, i32 31>
115   ret <16 x float> %shuffle
118 define <16 x float> @shuffle_v16f32_zz_12_zz_13_zz_16_zz_17_zz_1a_zz_1b_zz_1e_zz_1f(<16 x float> %a, <16 x float> %b) {
119 ; ALL-LABEL: shuffle_v16f32_zz_12_zz_13_zz_16_zz_17_zz_1a_zz_1b_zz_1e_zz_1f:
120 ; ALL:       # %bb.0:
121 ; ALL-NEXT:    vxorps %xmm0, %xmm0, %xmm0
122 ; ALL-NEXT:    vunpckhps {{.*#+}} zmm0 = zmm0[2],zmm1[2],zmm0[3],zmm1[3],zmm0[6],zmm1[6],zmm0[7],zmm1[7],zmm0[10],zmm1[10],zmm0[11],zmm1[11],zmm0[14],zmm1[14],zmm0[15],zmm1[15]
123 ; ALL-NEXT:    retq
124   %shuffle = shufflevector <16 x float> zeroinitializer, <16 x float> %b, <16 x i32><i32 0, i32 18, i32 0, i32 19, i32 4, i32 22, i32 4, i32 23, i32 6, i32 26, i32 6, i32 27, i32 8, i32 30, i32 8, i32 31>
125   ret <16 x float> %shuffle
128 define <16 x float> @shuffle_v16f32_00_00_02_02_04_04_06_06_08_08_10_10_12_12_14_14(<16 x float> %a, <16 x float> %b) {
129 ; ALL-LABEL: shuffle_v16f32_00_00_02_02_04_04_06_06_08_08_10_10_12_12_14_14:
130 ; ALL:       # %bb.0:
131 ; ALL-NEXT:    vmovsldup {{.*#+}} zmm0 = zmm0[0,0,2,2,4,4,6,6,8,8,10,10,12,12,14,14]
132 ; ALL-NEXT:    retq
133   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32><i32 0, i32 0, i32 2, i32 2, i32 4, i32 4, i32 6, i32 6, i32 8, i32 8, i32 10, i32 10, i32 12, i32 12, i32 14, i32 14>
134   ret <16 x float> %shuffle
137 define <16 x float> @shuffle_v16f32_01_01_03_03_05_05_07_07_09_09_11_11_13_13_15_15(<16 x float> %a, <16 x float> %b) {
138 ; ALL-LABEL: shuffle_v16f32_01_01_03_03_05_05_07_07_09_09_11_11_13_13_15_15:
139 ; ALL:       # %bb.0:
140 ; ALL-NEXT:    vmovshdup {{.*#+}} zmm0 = zmm0[1,1,3,3,5,5,7,7,9,9,11,11,13,13,15,15]
141 ; ALL-NEXT:    retq
142   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32><i32 1, i32 1, i32 3, i32 3, i32 5, i32 5, i32 7, i32 7, i32 9, i32 9, i32 11, i32 11, i32 13, i32 13, i32 15, i32 15>
143   ret <16 x float> %shuffle
146 define <16 x float> @shuffle_v16f32_00_01_00_01_06_07_06_07_08_09_10_11_12_13_12_13(<16 x float> %a, <16 x float> %b) {
147 ; ALL-LABEL: shuffle_v16f32_00_01_00_01_06_07_06_07_08_09_10_11_12_13_12_13:
148 ; ALL:       # %bb.0:
149 ; ALL-NEXT:    vshufpd {{.*#+}} zmm0 = zmm0[0,0,3,3,4,5,6,6]
150 ; ALL-NEXT:    retq
151   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 0, i32 1, i32 0, i32 1, i32 6, i32 7, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 12, i32 13>
152   ret <16 x float> %shuffle
155 define <16 x float> @shuffle_v16f32_00_00_02_00_04_04_06_04_08_08_10_08_12_12_14_12(<16 x float> %a, <16 x float> %b) {
156 ; ALL-LABEL: shuffle_v16f32_00_00_02_00_04_04_06_04_08_08_10_08_12_12_14_12:
157 ; ALL:       # %bb.0:
158 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[0,0,2,0,4,4,6,4,8,8,10,8,12,12,14,12]
159 ; ALL-NEXT:    retq
160   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 0, i32 0, i32 2, i32 0, i32 4, i32 4, i32 6, i32 4, i32 8, i32 8, i32 10, i32 8, i32 12, i32 12, i32 14, i32 12>
161   ret <16 x float> %shuffle
164 define <16 x float> @shuffle_v16f32_03_uu_uu_uu_uu_04_uu_uu_uu_uu_11_uu_uu_uu_uu_12(<16 x float> %a, <16 x float> %b) {
165 ; ALL-LABEL: shuffle_v16f32_03_uu_uu_uu_uu_04_uu_uu_uu_uu_11_uu_uu_uu_uu_12:
166 ; ALL:       # %bb.0:
167 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[3,0,3,0,7,4,7,4,11,8,11,8,15,12,15,12]
168 ; ALL-NEXT:    retq
169   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 3, i32 poison, i32 poison, i32 poison, i32 poison, i32 4, i32 poison, i32 poison, i32 poison, i32 poison, i32 11, i32 poison, i32 poison, i32 poison, i32 poison, i32 12>
170   ret <16 x float> %shuffle
173 ; PR41203
174 define <16 x float> @shuffle_v16f32_00_17_02_19_04_21_06_23_08_25_10_27_12_29_14_31(<16 x float> %a) {
175 ; ALL-LABEL: shuffle_v16f32_00_17_02_19_04_21_06_23_08_25_10_27_12_29_14_31:
176 ; ALL:       # %bb.0:
177 ; ALL-NEXT:    vandpd {{\.?LCPI[0-9]+_[0-9]+}}(%rip){1to8}, %zmm0, %zmm0
178 ; ALL-NEXT:    retq
179   %tmp1 = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> <i32 poison, i32 17, i32 poison, i32 19, i32 poison, i32 5, i32 poison, i32 7, i32 poison, i32 9, i32 poison, i32 11, i32 poison, i32 13, i32 poison, i32 15>
180   %tmp2 = shufflevector <16 x float> %tmp1, <16 x float> <float 0.000000e+00, float poison, float 0.000000e+00, float poison, float 0.000000e+00, float poison, float 0.000000e+00, float poison, float 0.000000e+00, float poison, float 0.000000e+00, float poison, float 0.000000e+00, float poison, float 0.000000e+00, float poison>, <16 x i32> <i32 16, i32 1, i32 18, i32 3, i32 20, i32 5, i32 22, i32 7, i32 24, i32 9, i32 26, i32 11, i32 28, i32 13, i32 30, i32 15>
181   ret <16 x float> %tmp2
184 ; PR48322
185 define <16 x float> @shuffle_v16f32_02_03_16_17_06_07_20_21_10_11_24_25_14_15_28_29(<16 x float> %a, <16 x float> %b) {
186 ; ALL-LABEL: shuffle_v16f32_02_03_16_17_06_07_20_21_10_11_24_25_14_15_28_29:
187 ; ALL:       # %bb.0:
188 ; ALL-NEXT:    vshufpd {{.*#+}} zmm0 = zmm0[1],zmm1[0],zmm0[3],zmm1[2],zmm0[5],zmm1[4],zmm0[7],zmm1[6]
189 ; ALL-NEXT:    retq
190   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 2, i32 3, i32 16, i32 17, i32 6, i32 7, i32 20, i32 21, i32 10, i32 11, i32 24, i32 25, i32 14, i32 15, i32 28, i32 29>
191   ret <16 x float> %shuffle
194 ; PR86076
195 define <16 x float> @shuffle_f32_v16f32_00_08_01_09_02_10_03_11_04_12_05_13_06_14_07_15(float %a0, float %a1) {
196 ; ALL-LABEL: shuffle_f32_v16f32_00_08_01_09_02_10_03_11_04_12_05_13_06_14_07_15:
197 ; ALL:       # %bb.0:
198 ; ALL-NEXT:    vbroadcastss %xmm0, %ymm0
199 ; ALL-NEXT:    vbroadcastss %xmm1, %ymm1
200 ; ALL-NEXT:    vunpcklps {{.*#+}} ymm0 = ymm0[0],ymm1[0],ymm0[1],ymm1[1],ymm0[4],ymm1[4],ymm0[5],ymm1[5]
201 ; ALL-NEXT:    vinsertf64x4 $1, %ymm0, %zmm0, %zmm0
202 ; ALL-NEXT:    retq
203   %v0 = insertelement <8 x float> poison, float %a0, i64 0
204   %v1 = insertelement <8 x float> poison, float %a1, i64 0
205   %b0 = shufflevector <8 x float> %v0, <8 x float> poison, <8 x i32> zeroinitializer
206   %b1 = shufflevector <8 x float> %v1, <8 x float> poison, <8 x i32> zeroinitializer
207   %r = shufflevector <8 x float> %b0, <8 x float> %b1, <16 x i32> <i32 0, i32 8, i32 1, i32 9, i32 2, i32 10, i32 3, i32 11, i32 4, i32 12, i32 5, i32 13, i32 6, i32 14, i32 7, i32 15>
208   ret <16 x float> %r
211 ; PR86076
212 define <16 x float> @shuffle_f32_v16f32_00_08_00_08_00_08_00_08_00_08_00_08_00_08_00_08(float %a0, float %a1) {
213 ; SLOW-LABEL: shuffle_f32_v16f32_00_08_00_08_00_08_00_08_00_08_00_08_00_08_00_08:
214 ; SLOW:       # %bb.0:
215 ; SLOW-NEXT:    vinsertps {{.*#+}} xmm0 = xmm0[0],xmm1[0],zero,zero
216 ; SLOW-NEXT:    vbroadcastsd %xmm0, %zmm0
217 ; SLOW-NEXT:    retq
219 ; FAST-LABEL: shuffle_f32_v16f32_00_08_00_08_00_08_00_08_00_08_00_08_00_08_00_08:
220 ; FAST:       # %bb.0:
221 ; FAST-NEXT:    # kill: def $xmm1 killed $xmm1 def $zmm1
222 ; FAST-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
223 ; FAST-NEXT:    vbroadcastsd {{.*#+}} ymm2 = [0,16,0,16,0,16,0,16]
224 ; FAST-NEXT:    vpermt2ps %zmm1, %zmm2, %zmm0
225 ; FAST-NEXT:    vinsertf64x4 $1, %ymm0, %zmm0, %zmm0
226 ; FAST-NEXT:    retq
227   %v0 = insertelement <8 x float> poison, float %a0, i64 0
228   %v1 = insertelement <8 x float> poison, float %a1, i64 0
229   %sv = shufflevector <8 x float> %v0, <8 x float> %v1, <16 x i32> <i32 0, i32 8, i32 0, i32 8, i32 0, i32 8, i32 0, i32 8, i32 0, i32 8, i32 0, i32 8, i32 0, i32 8, i32 0, i32 8>
230   ret <16 x float> %sv
233 define <16 x i32> @shuffle_v16i32_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00(<16 x i32> %a, <16 x i32> %b) {
234 ; ALL-LABEL: shuffle_v16i32_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00_00:
235 ; ALL:       # %bb.0:
236 ; ALL-NEXT:    vbroadcastss %xmm0, %zmm0
237 ; ALL-NEXT:    retq
238   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0>
239   ret <16 x i32> %shuffle
242 define <16 x i32> @shuffle_v16i32_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04(<16 x i32> %a, <16 x i32> %b) {
243 ; SLOW-LABEL: shuffle_v16i32_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04:
244 ; SLOW:       # %bb.0:
245 ; SLOW-NEXT:    vextractf128 $1, %ymm0, %xmm0
246 ; SLOW-NEXT:    vbroadcastss %xmm0, %zmm0
247 ; SLOW-NEXT:    retq
249 ; FAST-LABEL: shuffle_v16i32_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04:
250 ; FAST:       # %bb.0:
251 ; FAST-NEXT:    vbroadcastss {{.*#+}} zmm1 = [4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
252 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
253 ; FAST-NEXT:    retq
254   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
255   ret <16 x i32> %shuffle
258 define <16 x i32> @shuffle_v16i32_02_12_03_13_06_16_07_17_0a_1a_0b_1b_0e_1e_0f_1f(<16 x i32> %a, <16 x i32> %b) {
259 ; ALL-LABEL: shuffle_v16i32_02_12_03_13_06_16_07_17_0a_1a_0b_1b_0e_1e_0f_1f:
260 ; ALL:       # %bb.0:
261 ; ALL-NEXT:    vunpckhps {{.*#+}} zmm0 = zmm0[2],zmm1[2],zmm0[3],zmm1[3],zmm0[6],zmm1[6],zmm0[7],zmm1[7],zmm0[10],zmm1[10],zmm0[11],zmm1[11],zmm0[14],zmm1[14],zmm0[15],zmm1[15]
262 ; ALL-NEXT:    retq
263   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 2, i32 18, i32 3, i32 19, i32 6, i32 22, i32 7, i32 23, i32 10, i32 26, i32 11, i32 27, i32 14, i32 30, i32 15, i32 31>
264   ret <16 x i32> %shuffle
267 define <16 x i32> @shuffle_v16i32_02_zz_03_zz_06_zz_07_zz_0a_zz_0b_zz_0e_zz_0f_zz(<16 x i32> %a, <16 x i32> %b) {
268 ; ALL-LABEL: shuffle_v16i32_02_zz_03_zz_06_zz_07_zz_0a_zz_0b_zz_0e_zz_0f_zz:
269 ; ALL:       # %bb.0:
270 ; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
271 ; ALL-NEXT:    vunpckhps {{.*#+}} zmm0 = zmm0[2],zmm1[2],zmm0[3],zmm1[3],zmm0[6],zmm1[6],zmm0[7],zmm1[7],zmm0[10],zmm1[10],zmm0[11],zmm1[11],zmm0[14],zmm1[14],zmm0[15],zmm1[15]
272 ; ALL-NEXT:    retq
273   %shuffle = shufflevector <16 x i32> %a, <16 x i32> zeroinitializer, <16 x i32><i32 2, i32 30, i32 3, i32 28, i32 6, i32 26, i32 7, i32 24, i32 10, i32 22, i32 11, i32 20, i32 14, i32 18, i32 15, i32 16>
274   ret <16 x i32> %shuffle
277 define <16 x i32> @shuffle_v16i32_01_02_03_16_05_06_07_20_09_10_11_24_13_14_15_28(<16 x i32> %a, <16 x i32> %b) {
278 ; AVX512F-LABEL: shuffle_v16i32_01_02_03_16_05_06_07_20_09_10_11_24_13_14_15_28:
279 ; AVX512F:       # %bb.0:
280 ; AVX512F-NEXT:    vpmovsxbd {{.*#+}} zmm2 = [1,2,3,16,5,6,7,20,9,10,11,24,13,14,15,28]
281 ; AVX512F-NEXT:    vpermt2d %zmm1, %zmm2, %zmm0
282 ; AVX512F-NEXT:    retq
284 ; AVX512BW-LABEL: shuffle_v16i32_01_02_03_16_05_06_07_20_09_10_11_24_13_14_15_28:
285 ; AVX512BW:       # %bb.0:
286 ; AVX512BW-NEXT:    vpalignr {{.*#+}} zmm0 = zmm0[4,5,6,7,8,9,10,11,12,13,14,15],zmm1[0,1,2,3],zmm0[20,21,22,23,24,25,26,27,28,29,30,31],zmm1[16,17,18,19],zmm0[36,37,38,39,40,41,42,43,44,45,46,47],zmm1[32,33,34,35],zmm0[52,53,54,55,56,57,58,59,60,61,62,63],zmm1[48,49,50,51]
287 ; AVX512BW-NEXT:    retq
288   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 1, i32 2, i32 3, i32 16, i32 5, i32 6, i32 7, i32 20, i32 9, i32 10, i32 11, i32 24, i32 13, i32 14, i32 15, i32 28>
289   ret <16 x i32> %shuffle
292 define <16 x float> @shuffle_v16f32_02_05_u_u_07_u_0a_01_00_05_u_04_07_u_0a_01(<16 x float> %a)  {
293 ; ALL-LABEL: shuffle_v16f32_02_05_u_u_07_u_0a_01_00_05_u_04_07_u_0a_01:
294 ; ALL:       # %bb.0:
295 ; ALL-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [2,5,0,0,7,0,10,1,0,5,0,4,7,0,10,1]
296 ; ALL-NEXT:    vpermps %zmm0, %zmm1, %zmm0
297 ; ALL-NEXT:    retq
298   %c = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> <i32 2, i32 5, i32 poison, i32 poison, i32 7, i32 poison, i32 10, i32 1,  i32 0, i32 5, i32 poison, i32 4, i32 7, i32 poison, i32 10, i32 1>
299   ret <16 x float> %c
302 define <16 x i32> @shuffle_v16i32_02_05_u_u_07_u_0a_01_00_05_u_04_07_u_0a_01(<16 x i32> %a)  {
303 ; ALL-LABEL: shuffle_v16i32_02_05_u_u_07_u_0a_01_00_05_u_04_07_u_0a_01:
304 ; ALL:       # %bb.0:
305 ; ALL-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [2,5,0,0,7,0,10,1,0,5,0,4,7,0,10,1]
306 ; ALL-NEXT:    vpermps %zmm0, %zmm1, %zmm0
307 ; ALL-NEXT:    retq
308   %c = shufflevector <16 x i32> %a, <16 x i32> poison, <16 x i32> <i32 2, i32 5, i32 poison, i32 poison, i32 7, i32 poison, i32 10, i32 1,  i32 0, i32 5, i32 poison, i32 4, i32 7, i32 poison, i32 10, i32 1>
309   ret <16 x i32> %c
312 define <16 x i32> @shuffle_v16i32_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18(<16 x i32> %a, <16 x i32> %b)  {
313 ; ALL-LABEL: shuffle_v16i32_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18:
314 ; ALL:       # %bb.0:
315 ; ALL-NEXT:    vpmovsxbd {{.*#+}} zmm2 = [15,31,14,22,13,29,4,28,11,27,10,26,9,25,8,24]
316 ; ALL-NEXT:    vpermt2d %zmm1, %zmm2, %zmm0
317 ; ALL-NEXT:    retq
318   %c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
319   ret <16 x i32> %c
322 define <16 x float> @shuffle_v16f32_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18(<16 x float> %a, <16 x float> %b)  {
323 ; ALL-LABEL: shuffle_v16f32_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18:
324 ; ALL:       # %bb.0:
325 ; ALL-NEXT:    vpmovsxbd {{.*#+}} zmm2 = [15,31,14,22,13,29,4,28,11,27,10,26,9,25,8,24]
326 ; ALL-NEXT:    vpermt2ps %zmm1, %zmm2, %zmm0
327 ; ALL-NEXT:    retq
328   %c = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
329   ret <16 x float> %c
332 ; PR46249
333 define <16 x i32> @shuffle_v16i32_0b_0a_09_08_0f_0e_0d_0c_03_02_01_00_07_06_05_04(<16 x i32> %a) {
334 ; SLOW-LABEL: shuffle_v16i32_0b_0a_09_08_0f_0e_0d_0c_03_02_01_00_07_06_05_04:
335 ; SLOW:       # %bb.0:
336 ; SLOW-NEXT:    vpshufd {{.*#+}} zmm0 = zmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
337 ; SLOW-NEXT:    vshufi64x2 {{.*#+}} zmm0 = zmm0[4,5,6,7,0,1,2,3]
338 ; SLOW-NEXT:    retq
340 ; FAST-LABEL: shuffle_v16i32_0b_0a_09_08_0f_0e_0d_0c_03_02_01_00_07_06_05_04:
341 ; FAST:       # %bb.0:
342 ; FAST-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4]
343 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
344 ; FAST-NEXT:    retq
345   %1 = shufflevector <16 x i32> %a, <16 x i32> poison, <16 x i32> <i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12, i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
346   ret <16 x i32> %1
349 define <16 x float> @shuffle_v16f32_0b_0a_09_08_0f_0e_0d_0c_03_02_01_00_07_06_05_04(<16 x float> %a) {
350 ; SLOW-LABEL: shuffle_v16f32_0b_0a_09_08_0f_0e_0d_0c_03_02_01_00_07_06_05_04:
351 ; SLOW:       # %bb.0:
352 ; SLOW-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12]
353 ; SLOW-NEXT:    vshuff64x2 {{.*#+}} zmm0 = zmm0[4,5,6,7,0,1,2,3]
354 ; SLOW-NEXT:    retq
356 ; FAST-LABEL: shuffle_v16f32_0b_0a_09_08_0f_0e_0d_0c_03_02_01_00_07_06_05_04:
357 ; FAST:       # %bb.0:
358 ; FAST-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [11,10,9,8,15,14,13,12,3,2,1,0,7,6,5,4]
359 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
360 ; FAST-NEXT:    retq
361   %1 = shufflevector <16 x float> %a, <16 x float> poison, <16 x i32> <i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12, i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
362   ret <16 x float> %1
365 define <16 x float> @shuffle_v16f32_load_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18(<16 x float> %a, ptr %b)  {
366 ; ALL-LABEL: shuffle_v16f32_load_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18:
367 ; ALL:       # %bb.0:
368 ; ALL-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [15,31,14,22,13,29,4,28,11,27,10,26,9,25,8,24]
369 ; ALL-NEXT:    vpermt2ps (%rdi), %zmm1, %zmm0
370 ; ALL-NEXT:    retq
371   %c = load <16 x float>, ptr %b
372   %d = shufflevector <16 x float> %a, <16 x float> %c, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
373   ret <16 x float> %d
376 define <16 x float> @shuffle_v16f32_load_08_11_10_00_12_15_14_04(<16 x float> %a0, ptr %a1) {
377 ; SLOW-LABEL: shuffle_v16f32_load_08_11_10_00_12_15_14_04:
378 ; SLOW:       # %bb.0:
379 ; SLOW-NEXT:    vshufps {{.*#+}} zmm1 = zmm0[2,0],mem[0,0],zmm0[6,4],mem[4,4],zmm0[10,8],mem[8,8],zmm0[14,12],mem[12,12]
380 ; SLOW-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[0,3],zmm1[0,2],zmm0[4,7],zmm1[4,6],zmm0[8,11],zmm1[8,10],zmm0[12,15],zmm1[12,14]
381 ; SLOW-NEXT:    retq
383 ; FAST-LABEL: shuffle_v16f32_load_08_11_10_00_12_15_14_04:
384 ; FAST:       # %bb.0:
385 ; FAST-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [0,3,2,16,4,7,6,20,8,11,10,24,12,15,14,28]
386 ; FAST-NEXT:    vpermt2ps (%rdi), %zmm1, %zmm0
387 ; FAST-NEXT:    retq
388   %1 = load <16 x float>, ptr %a1
389   %2 = shufflevector <16 x float> %1, <16 x float> %a0, <16 x i32> <i32 16, i32 19, i32 18, i32 0, i32 20, i32 23, i32 22, i32 4, i32 24, i32 27, i32 26, i32 8, i32 28, i32 31, i32 30, i32 12>
390   ret <16 x float> %2
393 define <16 x i32> @shuffle_v16i32_load_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18(<16 x i32> %a, ptr %b)  {
394 ; ALL-LABEL: shuffle_v16i32_load_0f_1f_0e_16_0d_1d_04_1e_0b_1b_0a_1a_09_19_08_18:
395 ; ALL:       # %bb.0:
396 ; ALL-NEXT:    vpmovsxbd {{.*#+}} zmm1 = [15,31,14,22,13,29,4,28,11,27,10,26,9,25,8,24]
397 ; ALL-NEXT:    vpermt2d (%rdi), %zmm1, %zmm0
398 ; ALL-NEXT:    retq
399   %c = load <16 x i32>, ptr %b
400   %d = shufflevector <16 x i32> %a, <16 x i32> %c, <16 x i32> <i32 15, i32 31, i32 14, i32 22, i32 13, i32 29, i32 4, i32 28, i32 11, i32 27, i32 10, i32 26, i32 9, i32 25, i32 8, i32 24>
401   ret <16 x i32> %d
404 define <16 x i32> @shuffle_v16i32_0_1_2_19_u_u_u_u_u_u_u_u_u_u_u_u(<16 x i32> %a, <16 x i32> %b)  {
405 ; ALL-LABEL: shuffle_v16i32_0_1_2_19_u_u_u_u_u_u_u_u_u_u_u_u:
406 ; ALL:       # %bb.0:
407 ; ALL-NEXT:    vblendps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[3]
408 ; ALL-NEXT:    retq
409   %c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 19, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
410   ret <16 x i32> %c
413 ;FIXME: can do better with vpcompress
414 define <8 x i32> @test_v16i32_1_3_5_7_9_11_13_15(<16 x i32> %v) {
415 ; SLOW-LABEL: test_v16i32_1_3_5_7_9_11_13_15:
416 ; SLOW:       # %bb.0:
417 ; SLOW-NEXT:    vextractf64x4 $1, %zmm0, %ymm1
418 ; SLOW-NEXT:    vshufps {{.*#+}} ymm0 = ymm0[1,3],ymm1[1,3],ymm0[5,7],ymm1[5,7]
419 ; SLOW-NEXT:    vpermpd {{.*#+}} ymm0 = ymm0[0,2,1,3]
420 ; SLOW-NEXT:    retq
422 ; FAST-LABEL: test_v16i32_1_3_5_7_9_11_13_15:
423 ; FAST:       # %bb.0:
424 ; FAST-NEXT:    vpmovsxbd {{.*#+}} ymm1 = [1,3,5,7,9,11,13,15]
425 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
426 ; FAST-NEXT:    # kill: def $ymm0 killed $ymm0 killed $zmm0
427 ; FAST-NEXT:    retq
428   %res = shufflevector <16 x i32> %v, <16 x i32> poison, <8 x i32> <i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
429   ret <8 x i32> %res
432 ;FIXME: can do better with vpcompress
433 define <4 x i32> @test_v16i32_0_1_2_12 (<16 x i32> %v) {
434 ; SLOW-LABEL: test_v16i32_0_1_2_12:
435 ; SLOW:       # %bb.0:
436 ; SLOW-NEXT:    vextractf32x4 $3, %zmm0, %xmm1
437 ; SLOW-NEXT:    vbroadcastss %xmm1, %xmm1
438 ; SLOW-NEXT:    vblendps {{.*#+}} xmm0 = xmm0[0,1,2],xmm1[3]
439 ; SLOW-NEXT:    vzeroupper
440 ; SLOW-NEXT:    retq
442 ; FAST-LABEL: test_v16i32_0_1_2_12:
443 ; FAST:       # %bb.0:
444 ; FAST-NEXT:    vpmovsxbd {{.*#+}} xmm1 = [0,1,2,12]
445 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
446 ; FAST-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
447 ; FAST-NEXT:    vzeroupper
448 ; FAST-NEXT:    retq
449   %res = shufflevector <16 x i32> %v, <16 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 12>
450   ret <4 x i32> %res
453 ;PR31451
454 ;FIXME: can do better with vpcompress
455 define <4 x i32> @test_v16i32_0_4_8_12(<16 x i32> %v) {
456 ; ALL-LABEL: test_v16i32_0_4_8_12:
457 ; ALL:       # %bb.0:
458 ; ALL-NEXT:    vpmovsxbd {{.*#+}} xmm1 = [0,4,8,12]
459 ; ALL-NEXT:    vpermps %zmm0, %zmm1, %zmm0
460 ; ALL-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
461 ; ALL-NEXT:    vzeroupper
462 ; ALL-NEXT:    retq
463   %res = shufflevector <16 x i32> %v, <16 x i32> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
464   ret <4 x i32> %res
467 define <8 x float> @shuffle_v16f32_extract_256(ptr %RET, ptr %a) {
468 ; ALL-LABEL: shuffle_v16f32_extract_256:
469 ; ALL:       # %bb.0:
470 ; ALL-NEXT:    vmovups 32(%rsi), %ymm0
471 ; ALL-NEXT:    retq
472   %v_a = load <16 x float>, ptr %a, align 4
473   %v2 = shufflevector <16 x float> %v_a, <16 x float> poison, <8 x i32>  <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
474   ret <8 x float> %v2
477 ;FIXME: can do better with vcompressp
478 define <8 x float> @test_v16f32_0_1_2_3_4_6_7_10 (<16 x float> %v) {
479 ; ALL-LABEL: test_v16f32_0_1_2_3_4_6_7_10:
480 ; ALL:       # %bb.0:
481 ; ALL-NEXT:    vpmovsxbd {{.*#+}} ymm1 = [0,1,2,3,4,6,7,10]
482 ; ALL-NEXT:    vpermps %zmm0, %zmm1, %zmm0
483 ; ALL-NEXT:    # kill: def $ymm0 killed $ymm0 killed $zmm0
484 ; ALL-NEXT:    retq
485   %res = shufflevector <16 x float> %v, <16 x float> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 6, i32 7, i32 10>
486   ret <8 x float> %res
489 ;FIXME: can do better with vcompressp
490 define <4 x float> @test_v16f32_0_1_3_6 (<16 x float> %v) {
491 ; ALL-LABEL: test_v16f32_0_1_3_6:
492 ; ALL:       # %bb.0:
493 ; ALL-NEXT:    vpmovsxbd {{.*#+}} xmm1 = [0,1,3,6]
494 ; ALL-NEXT:    vpermps %zmm0, %zmm1, %zmm0
495 ; ALL-NEXT:    # kill: def $xmm0 killed $xmm0 killed $zmm0
496 ; ALL-NEXT:    vzeroupper
497 ; ALL-NEXT:    retq
498   %res = shufflevector <16 x float> %v, <16 x float> poison, <4 x i32> <i32 0, i32 1, i32 3, i32 6>
499   ret <4 x float> %res
502 define <16 x i32> @shuffle_v16i16_1_0_0_0_5_4_4_4_9_8_8_8_13_12_12_12(<16 x i32> %a, <16 x i32> %b)  {
503 ; ALL-LABEL: shuffle_v16i16_1_0_0_0_5_4_4_4_9_8_8_8_13_12_12_12:
504 ; ALL:       # %bb.0:
505 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[1,0,0,0,5,4,4,4,9,8,8,8,13,12,12,12]
506 ; ALL-NEXT:    retq
507   %c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 1, i32 0, i32 0, i32 0, i32 5, i32 4, i32 4, i32 4, i32 9, i32 8, i32 8, i32 8, i32 13, i32 12, i32 12, i32 12>
508   ret <16 x i32> %c
511 define <16 x i32> @shuffle_v16i16_3_3_0_0_7_7_4_4_11_11_8_8_15_15_12_12(<16 x i32> %a, <16 x i32> %b)  {
512 ; ALL-LABEL: shuffle_v16i16_3_3_0_0_7_7_4_4_11_11_8_8_15_15_12_12:
513 ; ALL:       # %bb.0:
514 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13]
515 ; ALL-NEXT:    retq
516   %c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 2, i32 3, i32 0, i32 1, i32 6, i32 7, i32 4, i32 5, i32 10, i32 11, i32 8, i32 9, i32 14, i32 15, i32 12, i32 13>
517   ret <16 x i32> %c
520 define <16 x float> @shuffle_v16f32_00_01_10_10_04_05_14_14_08_09_18_18_0c_0d_1c_1c(<16 x float> %a, <16 x float> %b) {
521 ; ALL-LABEL: shuffle_v16f32_00_01_10_10_04_05_14_14_08_09_18_18_0c_0d_1c_1c:
522 ; ALL:       # %bb.0:
523 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[0,1],zmm1[0,0],zmm0[4,5],zmm1[4,4],zmm0[8,9],zmm1[8,8],zmm0[12,13],zmm1[12,12]
524 ; ALL-NEXT:    retq
525   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 0, i32 1, i32 16, i32 16, i32 4, i32 5, i32 20, i32 20, i32 8, i32 9, i32 24, i32 24, i32 12, i32 13, i32 28, i32 28>
526   ret <16 x float> %shuffle
529 define <16 x i32> @insert_mem_and_zero_v16i32(ptr %ptr) {
530 ; ALL-LABEL: insert_mem_and_zero_v16i32:
531 ; ALL:       # %bb.0:
532 ; ALL-NEXT:    vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
533 ; ALL-NEXT:    retq
534   %a = load i32, ptr %ptr
535   %v = insertelement <16 x i32> poison, i32 %a, i32 0
536   %shuffle = shufflevector <16 x i32> %v, <16 x i32> zeroinitializer, <16 x i32> <i32 0, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
537   ret <16 x i32> %shuffle
541 define <16 x i32> @shuffle_v16i32_0zzzzzzzzzzzzzzz(<16 x i32> %a) {
542 ; ALL-LABEL: shuffle_v16i32_0zzzzzzzzzzzzzzz:
543 ; ALL:       # %bb.0:
544 ; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
545 ; ALL-NEXT:    vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
546 ; ALL-NEXT:    retq
547   %shuffle = shufflevector <16 x i32> %a, <16 x i32> zeroinitializer, <16 x i32> <i32 0, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
548   ret <16 x i32> %shuffle
551 define <16 x float> @shuffle_v16f32_0zzzzzzzzzzzzzzz(<16 x float> %a) {
552 ; ALL-LABEL: shuffle_v16f32_0zzzzzzzzzzzzzzz:
553 ; ALL:       # %bb.0:
554 ; ALL-NEXT:    vxorps %xmm1, %xmm1, %xmm1
555 ; ALL-NEXT:    vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
556 ; ALL-NEXT:    retq
557   %shuffle = shufflevector <16 x float> %a, <16 x float> zeroinitializer, <16 x i32> <i32 0, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
558   ret <16 x float> %shuffle
561 define <16 x i32> @shuffle_v16i32_16_zz_17_zz_18_zz_19_zz_20_zz_21_zz_22_zz_23_zz(<16 x i32> %a) {
562 ; ALL-LABEL: shuffle_v16i32_16_zz_17_zz_18_zz_19_zz_20_zz_21_zz_22_zz_23_zz:
563 ; ALL:       # %bb.0:
564 ; ALL-NEXT:    vpmovzxdq {{.*#+}} zmm0 = ymm0[0],zero,ymm0[1],zero,ymm0[2],zero,ymm0[3],zero,ymm0[4],zero,ymm0[5],zero,ymm0[6],zero,ymm0[7],zero
565 ; ALL-NEXT:    retq
566   %shuffle = shufflevector <16 x i32> zeroinitializer, <16 x i32> %a, <16 x i32> <i32 16, i32 0, i32 17, i32 0, i32 18, i32 0, i32 19, i32 0, i32 20, i32 0, i32 21, i32 0, i32 22, i32 0, i32 23, i32 0>
567   ret <16 x i32> %shuffle
570 define <16 x i32> @shuffle_v16i32_01_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16(<16 x i32> %a, <16 x i32> %b) {
571 ; ALL-LABEL: shuffle_v16i32_01_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16:
572 ; ALL:       # %bb.0:
573 ; ALL-NEXT:    valignd {{.*#+}} zmm0 = zmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],zmm1[0]
574 ; ALL-NEXT:    retq
575   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>
576   ret <16 x i32> %shuffle
579 define <16 x i32> @shuffle_v16i32_01_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00(<16 x i32> %a) {
580 ; ALL-LABEL: shuffle_v16i32_01_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00:
581 ; ALL:       # %bb.0:
582 ; ALL-NEXT:    valignd {{.*#+}} zmm0 = zmm0[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0]
583 ; ALL-NEXT:    retq
584   %shuffle = shufflevector <16 x i32> %a, <16 x i32> poison, <16 x i32><i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 0>
585   ret <16 x i32> %shuffle
588 define <16 x i32> @shuffle_v16i32_00_03_16_19_04_07_20_23_08_11_24_27_12_15_28_31(<16 x i32> %a, <16 x i32> %b) {
589 ; ALL-LABEL: shuffle_v16i32_00_03_16_19_04_07_20_23_08_11_24_27_12_15_28_31:
590 ; ALL:       # %bb.0:
591 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm0[0,3],zmm1[0,3],zmm0[4,7],zmm1[4,7],zmm0[8,11],zmm1[8,11],zmm0[12,15],zmm1[12,15]
592 ; ALL-NEXT:    retq
593   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 3, i32 16, i32 19, i32 4, i32 7, i32 20, i32 23, i32 8, i32 11, i32 24, i32 27, i32 12, i32 15, i32 28, i32 31>
594   ret <16 x i32> %shuffle
597 define <16 x i32> @shuffle_v16i32_16_16_02_03_20_20_06_07_24_24_10_11_28_28_uu_uu(<16 x i32> %a, <16 x i32> %b) {
598 ; ALL-LABEL: shuffle_v16i32_16_16_02_03_20_20_06_07_24_24_10_11_28_28_uu_uu:
599 ; ALL:       # %bb.0:
600 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm1[0,0],zmm0[2,3],zmm1[4,4],zmm0[6,7],zmm1[8,8],zmm0[10,11],zmm1[12,12],zmm0[14,15]
601 ; ALL-NEXT:    retq
602   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 16, i32 16, i32 02, i32 03, i32 20, i32 20, i32 06, i32 07, i32 24, i32 24, i32 10, i32 11, i32 28, i32 28, i32 poison, i32 poison>
603   ret <16 x i32> %shuffle
606 ; PR48322
607 define <16 x i32> @shuffle_v16i32_02_03_16_17_06_07_20_21_10_11_24_25_14_15_28_29(<16 x i32> %a, <16 x i32> %b) {
608 ; AVX512F-LABEL: shuffle_v16i32_02_03_16_17_06_07_20_21_10_11_24_25_14_15_28_29:
609 ; AVX512F:       # %bb.0:
610 ; AVX512F-NEXT:    vpmovsxbq {{.*#+}} zmm2 = [1,8,3,10,5,12,7,14]
611 ; AVX512F-NEXT:    vpermt2q %zmm1, %zmm2, %zmm0
612 ; AVX512F-NEXT:    retq
614 ; AVX512BW-LABEL: shuffle_v16i32_02_03_16_17_06_07_20_21_10_11_24_25_14_15_28_29:
615 ; AVX512BW:       # %bb.0:
616 ; AVX512BW-NEXT:    vpalignr {{.*#+}} zmm0 = zmm0[8,9,10,11,12,13,14,15],zmm1[0,1,2,3,4,5,6,7],zmm0[24,25,26,27,28,29,30,31],zmm1[16,17,18,19,20,21,22,23],zmm0[40,41,42,43,44,45,46,47],zmm1[32,33,34,35,36,37,38,39],zmm0[56,57,58,59,60,61,62,63],zmm1[48,49,50,51,52,53,54,55]
617 ; AVX512BW-NEXT:    retq
618   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 2, i32 3, i32 16, i32 17, i32 6, i32 7, i32 20, i32 21, i32 10, i32 11, i32 24, i32 25, i32 14, i32 15, i32 28, i32 29>
619   ret <16 x i32> %shuffle
622 define <16 x i32> @shuffle_v8i32_17_16_01_00_21_20_05_04_25_24_09_08_29_28_13_12(<16 x i32> %a, <16 x i32> %b) {
623 ; ALL-LABEL: shuffle_v8i32_17_16_01_00_21_20_05_04_25_24_09_08_29_28_13_12:
624 ; ALL:       # %bb.0:
625 ; ALL-NEXT:    vshufps {{.*#+}} zmm0 = zmm1[1,0],zmm0[1,0],zmm1[5,4],zmm0[5,4],zmm1[9,8],zmm0[9,8],zmm1[13,12],zmm0[13,12]
626 ; ALL-NEXT:    retq
627   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 17, i32 16, i32 01, i32 00, i32 21, i32 20, i32 05, i32 04, i32 25, i32 24, i32 09, i32 08, i32 29, i32 28, i32 13, i32 12>
628   ret <16 x i32> %shuffle
631 define <16 x float> @shuffle_v8f32_v16f32_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04(<8 x float> %a) {
632 ; SLOW-LABEL: shuffle_v8f32_v16f32_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04:
633 ; SLOW:       # %bb.0:
634 ; SLOW-NEXT:    vextractf128 $1, %ymm0, %xmm0
635 ; SLOW-NEXT:    vbroadcastss %xmm0, %zmm0
636 ; SLOW-NEXT:    retq
638 ; FAST-LABEL: shuffle_v8f32_v16f32_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04_04:
639 ; FAST:       # %bb.0:
640 ; FAST-NEXT:    # kill: def $ymm0 killed $ymm0 def $zmm0
641 ; FAST-NEXT:    vbroadcastss {{.*#+}} zmm1 = [4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
642 ; FAST-NEXT:    vpermps %zmm0, %zmm1, %zmm0
643 ; FAST-NEXT:    retq
644   %shuffle = shufflevector <8 x float> %a, <8 x float> poison, <16 x i32> <i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4, i32 4>
645   ret <16 x float> %shuffle
648 define <16 x float> @insert_sub0_0(<16 x float> %base, <4 x float> %sub1, <4 x float> %sub2, <4 x float> %sub3, <4 x float> %sub4) {
649 ; ALL-LABEL: insert_sub0_0:
650 ; ALL:       # %bb.0:
651 ; ALL-NEXT:    vinsertf32x4 $0, %xmm1, %zmm0, %zmm0
652 ; ALL-NEXT:    retq
653   %sub12 = shufflevector <4 x float> %sub1, <4 x float> %sub2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
654   %sub34 = shufflevector <4 x float> %sub3, <4 x float> %sub4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
655   %sub1234 = shufflevector <8 x float> %sub12, <8 x float> %sub34, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
656   %res = shufflevector <16 x float> %base, <16 x float> %sub1234, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
657   ret <16 x float> %res
660 define <16 x float> @insert_sub1_12(<16 x float> %base, <4 x float> %sub1, <4 x float> %sub2, <4 x float> %sub3, <4 x float> %sub4) {
661 ; ALL-LABEL: insert_sub1_12:
662 ; ALL:       # %bb.0:
663 ; ALL-NEXT:    vinsertf32x4 $3, %xmm2, %zmm0, %zmm0
664 ; ALL-NEXT:    retq
665   %sub12 = shufflevector <4 x float> %sub1, <4 x float> %sub2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
666   %sub34 = shufflevector <4 x float> %sub3, <4 x float> %sub4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
667   %sub1234 = shufflevector <8 x float> %sub12, <8 x float> %sub34, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
668   %res = shufflevector <16 x float> %base, <16 x float> %sub1234, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 20, i32 21, i32 22, i32 23>
669   ret <16 x float> %res
672 define <16 x float> @insert_sub2_4(<16 x float> %base, <4 x float> %sub1, <4 x float> %sub2, <4 x float> %sub3, <4 x float> %sub4) {
673 ; ALL-LABEL: insert_sub2_4:
674 ; ALL:       # %bb.0:
675 ; ALL-NEXT:    vinsertf32x4 $1, %xmm3, %zmm0, %zmm0
676 ; ALL-NEXT:    retq
677   %sub12 = shufflevector <4 x float> %sub1, <4 x float> %sub2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
678   %sub34 = shufflevector <4 x float> %sub3, <4 x float> %sub4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
679   %sub1234 = shufflevector <8 x float> %sub12, <8 x float> %sub34, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
680   %res = shufflevector <16 x float> %base, <16 x float> %sub1234, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 24, i32 25, i32 26, i32 27, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
681   ret <16 x float> %res
684 define <16 x float> @insert_sub01_8(<16 x float> %base, <4 x float> %sub1, <4 x float> %sub2, <4 x float> %sub3, <4 x float> %sub4) {
685 ; ALL-LABEL: insert_sub01_8:
686 ; ALL:       # %bb.0:
687 ; ALL-NEXT:    # kill: def $xmm1 killed $xmm1 def $ymm1
688 ; ALL-NEXT:    vinsertf128 $1, %xmm2, %ymm1, %ymm1
689 ; ALL-NEXT:    vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
690 ; ALL-NEXT:    retq
691   %sub12 = shufflevector <4 x float> %sub1, <4 x float> %sub2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
692   %sub34 = shufflevector <4 x float> %sub3, <4 x float> %sub4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
693   %sub1234 = shufflevector <8 x float> %sub12, <8 x float> %sub34, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
694   %res = shufflevector <16 x float> %base, <16 x float> %sub1234, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
695   ret <16 x float> %res
698 define <16 x float> @insert_sub23_0(<16 x float> %base, <4 x float> %sub1, <4 x float> %sub2, <4 x float> %sub3, <4 x float> %sub4) {
699 ; ALL-LABEL: insert_sub23_0:
700 ; ALL:       # %bb.0:
701 ; ALL-NEXT:    # kill: def $xmm3 killed $xmm3 def $ymm3
702 ; ALL-NEXT:    vinsertf128 $1, %xmm4, %ymm3, %ymm1
703 ; ALL-NEXT:    vinsertf64x4 $0, %ymm1, %zmm0, %zmm0
704 ; ALL-NEXT:    retq
705   %sub12 = shufflevector <4 x float> %sub1, <4 x float> %sub2, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
706   %sub34 = shufflevector <4 x float> %sub3, <4 x float> %sub4, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
707   %sub1234 = shufflevector <8 x float> %sub12, <8 x float> %sub34, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
708   %res = shufflevector <16 x float> %base, <16 x float> %sub1234, <16 x i32> <i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
709   ret <16 x float> %res
712 define <16 x i32> @mask_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00_01(<16 x i32> %a, <16 x i32> %passthru, i16 %mask) {
713 ; AVX512F-LABEL: mask_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00_01:
714 ; AVX512F:       # %bb.0:
715 ; AVX512F-NEXT:    kmovw %edi, %k1
716 ; AVX512F-NEXT:    valignd {{.*#+}} zmm1 {%k1} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1]
717 ; AVX512F-NEXT:    vmovdqa64 %zmm1, %zmm0
718 ; AVX512F-NEXT:    retq
720 ; AVX512BW-LABEL: mask_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00_01:
721 ; AVX512BW:       # %bb.0:
722 ; AVX512BW-NEXT:    kmovd %edi, %k1
723 ; AVX512BW-NEXT:    valignd {{.*#+}} zmm1 {%k1} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1]
724 ; AVX512BW-NEXT:    vmovdqa64 %zmm1, %zmm0
725 ; AVX512BW-NEXT:    retq
726   %shuffle = shufflevector <16 x i32> %a, <16 x i32> poison, <16 x i32><i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 0, i32 1>
727   %mask.cast = bitcast i16 %mask to <16 x i1>
728   %res = select <16 x i1> %mask.cast, <16 x i32> %shuffle, <16 x i32> %passthru
729   ret <16 x i32> %res
732 define <16 x i32> @mask_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16_17(<16 x i32> %a, <16 x i32> %b, <16 x i32> %passthru, i16 %mask) {
733 ; AVX512F-LABEL: mask_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16_17:
734 ; AVX512F:       # %bb.0:
735 ; AVX512F-NEXT:    kmovw %edi, %k1
736 ; AVX512F-NEXT:    valignd {{.*#+}} zmm2 {%k1} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zmm1[0,1]
737 ; AVX512F-NEXT:    vmovdqa64 %zmm2, %zmm0
738 ; AVX512F-NEXT:    retq
740 ; AVX512BW-LABEL: mask_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16_17:
741 ; AVX512BW:       # %bb.0:
742 ; AVX512BW-NEXT:    kmovd %edi, %k1
743 ; AVX512BW-NEXT:    valignd {{.*#+}} zmm2 {%k1} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zmm1[0,1]
744 ; AVX512BW-NEXT:    vmovdqa64 %zmm2, %zmm0
745 ; AVX512BW-NEXT:    retq
746   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17>
747   %mask.cast = bitcast i16 %mask to <16 x i1>
748   %res = select <16 x i1> %mask.cast, <16 x i32> %shuffle, <16 x i32> %passthru
749   ret <16 x i32> %res
752 define <16 x i32> @maskz_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00_01(<16 x i32> %a, i16 %mask) {
753 ; AVX512F-LABEL: maskz_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00_01:
754 ; AVX512F:       # %bb.0:
755 ; AVX512F-NEXT:    kmovw %edi, %k1
756 ; AVX512F-NEXT:    valignd {{.*#+}} zmm0 {%k1} {z} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1]
757 ; AVX512F-NEXT:    retq
759 ; AVX512BW-LABEL: maskz_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_00_01:
760 ; AVX512BW:       # %bb.0:
761 ; AVX512BW-NEXT:    kmovd %edi, %k1
762 ; AVX512BW-NEXT:    valignd {{.*#+}} zmm0 {%k1} {z} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1]
763 ; AVX512BW-NEXT:    retq
764   %shuffle = shufflevector <16 x i32> %a, <16 x i32> poison, <16 x i32><i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 0, i32 1>
765   %mask.cast = bitcast i16 %mask to <16 x i1>
766   %res = select <16 x i1> %mask.cast, <16 x i32> %shuffle, <16 x i32> zeroinitializer
767   ret <16 x i32> %res
770 define <16 x i32> @maskz_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16_17(<16 x i32> %a, <16 x i32> %b, i16 %mask) {
771 ; AVX512F-LABEL: maskz_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16_17:
772 ; AVX512F:       # %bb.0:
773 ; AVX512F-NEXT:    kmovw %edi, %k1
774 ; AVX512F-NEXT:    valignd {{.*#+}} zmm0 {%k1} {z} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zmm1[0,1]
775 ; AVX512F-NEXT:    retq
777 ; AVX512BW-LABEL: maskz_shuffle_v16i32_02_03_04_05_06_07_08_09_10_11_12_13_14_15_16_17:
778 ; AVX512BW:       # %bb.0:
779 ; AVX512BW-NEXT:    kmovd %edi, %k1
780 ; AVX512BW-NEXT:    valignd {{.*#+}} zmm0 {%k1} {z} = zmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zmm1[0,1]
781 ; AVX512BW-NEXT:    retq
782   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32><i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17>
783   %mask.cast = bitcast i16 %mask to <16 x i1>
784   %res = select <16 x i1> %mask.cast, <16 x i32> %shuffle, <16 x i32> zeroinitializer
785   ret <16 x i32> %res
788 define <16 x float> @test_vshuff32x4_512(<16 x float> %x, <16 x float> %x1) nounwind {
789 ; ALL-LABEL: test_vshuff32x4_512:
790 ; ALL:       # %bb.0:
791 ; ALL-NEXT:    vshuff64x2 {{.*#+}} zmm0 = zmm0[0,1,2,3],zmm1[2,3,0,1]
792 ; ALL-NEXT:    retq
793   %res = shufflevector <16 x float> %x, <16 x float> %x1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 20, i32 21, i32 22, i32 23, i32 16, i32 17, i32 18, i32 19>
794   ret <16 x float> %res
797 define <16 x i32> @test_vshufi32x4_512(<16 x i32> %x, <16 x i32> %x1) nounwind {
798 ; ALL-LABEL: test_vshufi32x4_512:
799 ; ALL:       # %bb.0:
800 ; ALL-NEXT:    vshufi64x2 {{.*#+}} zmm0 = zmm0[0,1,2,3],zmm1[2,3,0,1]
801 ; ALL-NEXT:    retq
802   %res = shufflevector <16 x i32> %x, <16 x i32> %x1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 20, i32 21, i32 22, i32 23, i32 16, i32 17, i32 18, i32 19>
803   ret <16 x i32> %res
806 define <16 x float> @test_vshuff32x4_512_mask(<16 x float> %x, <16 x float> %x1, <16 x float> %y, <16 x i1> %mask) nounwind {
807 ; AVX512F-LABEL: test_vshuff32x4_512_mask:
808 ; AVX512F:       # %bb.0:
809 ; AVX512F-NEXT:    vpmovsxbd %xmm3, %zmm3
810 ; AVX512F-NEXT:    vpslld $31, %zmm3, %zmm3
811 ; AVX512F-NEXT:    vpmovd2m %zmm3, %k1
812 ; AVX512F-NEXT:    vshuff32x4 {{.*#+}} zmm2 {%k1} = zmm0[0,1,2,3,4,5,6,7],zmm1[4,5,6,7,0,1,2,3]
813 ; AVX512F-NEXT:    vmovaps %zmm2, %zmm0
814 ; AVX512F-NEXT:    retq
816 ; AVX512BW-LABEL: test_vshuff32x4_512_mask:
817 ; AVX512BW:       # %bb.0:
818 ; AVX512BW-NEXT:    vpsllw $7, %xmm3, %xmm3
819 ; AVX512BW-NEXT:    vpmovb2m %zmm3, %k1
820 ; AVX512BW-NEXT:    vshuff32x4 {{.*#+}} zmm2 {%k1} = zmm0[0,1,2,3,4,5,6,7],zmm1[4,5,6,7,0,1,2,3]
821 ; AVX512BW-NEXT:    vmovaps %zmm2, %zmm0
822 ; AVX512BW-NEXT:    retq
823   %x2 = shufflevector <16 x float> %x, <16 x float> %x1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 20, i32 21, i32 22, i32 23, i32 16, i32 17, i32 18, i32 19>
824   %res = select <16 x i1> %mask, <16 x float> %x2, <16 x float> %y
825   ret <16 x float> %res
828 define <16 x i32> @test_vshufi32x4_512_mask(<16 x i32> %x, <16 x i32> %x1, <16 x i32> %y, <16 x i1> %mask) nounwind {
829 ; AVX512F-LABEL: test_vshufi32x4_512_mask:
830 ; AVX512F:       # %bb.0:
831 ; AVX512F-NEXT:    vpmovsxbd %xmm3, %zmm3
832 ; AVX512F-NEXT:    vpslld $31, %zmm3, %zmm3
833 ; AVX512F-NEXT:    vpmovd2m %zmm3, %k1
834 ; AVX512F-NEXT:    vshufi32x4 {{.*#+}} zmm2 {%k1} = zmm0[0,1,2,3,4,5,6,7],zmm1[4,5,6,7,0,1,2,3]
835 ; AVX512F-NEXT:    vmovdqa64 %zmm2, %zmm0
836 ; AVX512F-NEXT:    retq
838 ; AVX512BW-LABEL: test_vshufi32x4_512_mask:
839 ; AVX512BW:       # %bb.0:
840 ; AVX512BW-NEXT:    vpsllw $7, %xmm3, %xmm3
841 ; AVX512BW-NEXT:    vpmovb2m %zmm3, %k1
842 ; AVX512BW-NEXT:    vshufi32x4 {{.*#+}} zmm2 {%k1} = zmm0[0,1,2,3,4,5,6,7],zmm1[4,5,6,7,0,1,2,3]
843 ; AVX512BW-NEXT:    vmovdqa64 %zmm2, %zmm0
844 ; AVX512BW-NEXT:    retq
845   %x2 = shufflevector <16 x i32> %x, <16 x i32> %x1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 20, i32 21, i32 22, i32 23, i32 16, i32 17, i32 18, i32 19>
846   %res = select <16 x i1> %mask, <16 x i32> %x2, <16 x i32> %y
847   ret <16 x i32> %res
850 define <16 x float> @mask_shuffle_v16f32_00_01_02_03_04_05_06_07_16_17_18_19_20_21_22_23(<16 x float> %a, <16 x float> %b, <16 x float> %passthru, i16 %mask) {
851 ; AVX512F-LABEL: mask_shuffle_v16f32_00_01_02_03_04_05_06_07_16_17_18_19_20_21_22_23:
852 ; AVX512F:       # %bb.0:
853 ; AVX512F-NEXT:    kmovw %edi, %k1
854 ; AVX512F-NEXT:    vinsertf32x8 $1, %ymm1, %zmm0, %zmm2 {%k1}
855 ; AVX512F-NEXT:    vmovaps %zmm2, %zmm0
856 ; AVX512F-NEXT:    retq
858 ; AVX512BW-LABEL: mask_shuffle_v16f32_00_01_02_03_04_05_06_07_16_17_18_19_20_21_22_23:
859 ; AVX512BW:       # %bb.0:
860 ; AVX512BW-NEXT:    kmovd %edi, %k1
861 ; AVX512BW-NEXT:    vinsertf32x8 $1, %ymm1, %zmm0, %zmm2 {%k1}
862 ; AVX512BW-NEXT:    vmovaps %zmm2, %zmm0
863 ; AVX512BW-NEXT:    retq
864   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
865   %mask.cast = bitcast i16 %mask to <16 x i1>
866   %res = select <16 x i1> %mask.cast, <16 x float> %shuffle, <16 x float> %passthru
867   ret <16 x float> %res
870 define <16 x float> @mask_shuffle_v16f32_00_01_02_03_16_17_18_19_08_09_10_11_12_13_14_15(<16 x float> %a, <16 x float> %b, <16 x float> %passthru, i16 %mask) {
871 ; AVX512F-LABEL: mask_shuffle_v16f32_00_01_02_03_16_17_18_19_08_09_10_11_12_13_14_15:
872 ; AVX512F:       # %bb.0:
873 ; AVX512F-NEXT:    kmovw %edi, %k1
874 ; AVX512F-NEXT:    vinsertf32x4 $1, %xmm1, %zmm0, %zmm2 {%k1}
875 ; AVX512F-NEXT:    vmovaps %zmm2, %zmm0
876 ; AVX512F-NEXT:    retq
878 ; AVX512BW-LABEL: mask_shuffle_v16f32_00_01_02_03_16_17_18_19_08_09_10_11_12_13_14_15:
879 ; AVX512BW:       # %bb.0:
880 ; AVX512BW-NEXT:    kmovd %edi, %k1
881 ; AVX512BW-NEXT:    vinsertf32x4 $1, %xmm1, %zmm0, %zmm2 {%k1}
882 ; AVX512BW-NEXT:    vmovaps %zmm2, %zmm0
883 ; AVX512BW-NEXT:    retq
884   %shuffle = shufflevector <16 x float> %a, <16 x float> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 16, i32 17, i32 18, i32 19, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
885   %mask.cast = bitcast i16 %mask to <16 x i1>
886   %res = select <16 x i1> %mask.cast, <16 x float> %shuffle, <16 x float> %passthru
887   ret <16 x float> %res
890 define <16 x i32> @mask_shuffle_v16i32_00_01_02_03_04_05_06_07_16_17_18_19_20_21_22_23(<16 x i32> %a, <16 x i32> %b, <16 x i32> %passthru, i16 %mask) {
891 ; AVX512F-LABEL: mask_shuffle_v16i32_00_01_02_03_04_05_06_07_16_17_18_19_20_21_22_23:
892 ; AVX512F:       # %bb.0:
893 ; AVX512F-NEXT:    kmovw %edi, %k1
894 ; AVX512F-NEXT:    vinserti32x8 $1, %ymm1, %zmm0, %zmm2 {%k1}
895 ; AVX512F-NEXT:    vmovdqa64 %zmm2, %zmm0
896 ; AVX512F-NEXT:    retq
898 ; AVX512BW-LABEL: mask_shuffle_v16i32_00_01_02_03_04_05_06_07_16_17_18_19_20_21_22_23:
899 ; AVX512BW:       # %bb.0:
900 ; AVX512BW-NEXT:    kmovd %edi, %k1
901 ; AVX512BW-NEXT:    vinserti32x8 $1, %ymm1, %zmm0, %zmm2 {%k1}
902 ; AVX512BW-NEXT:    vmovdqa64 %zmm2, %zmm0
903 ; AVX512BW-NEXT:    retq
904   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
905   %mask.cast = bitcast i16 %mask to <16 x i1>
906   %res = select <16 x i1> %mask.cast, <16 x i32> %shuffle, <16 x i32> %passthru
907   ret <16 x i32> %res
910 define <16 x i32> @mask_shuffle_v16i32_00_01_02_03_16_17_18_19_08_09_10_11_12_13_14_15(<16 x i32> %a, <16 x i32> %b, <16 x i32> %passthru, i16 %mask) {
911 ; AVX512F-LABEL: mask_shuffle_v16i32_00_01_02_03_16_17_18_19_08_09_10_11_12_13_14_15:
912 ; AVX512F:       # %bb.0:
913 ; AVX512F-NEXT:    kmovw %edi, %k1
914 ; AVX512F-NEXT:    vinserti32x4 $1, %xmm1, %zmm0, %zmm2 {%k1}
915 ; AVX512F-NEXT:    vmovdqa64 %zmm2, %zmm0
916 ; AVX512F-NEXT:    retq
918 ; AVX512BW-LABEL: mask_shuffle_v16i32_00_01_02_03_16_17_18_19_08_09_10_11_12_13_14_15:
919 ; AVX512BW:       # %bb.0:
920 ; AVX512BW-NEXT:    kmovd %edi, %k1
921 ; AVX512BW-NEXT:    vinserti32x4 $1, %xmm1, %zmm0, %zmm2 {%k1}
922 ; AVX512BW-NEXT:    vmovdqa64 %zmm2, %zmm0
923 ; AVX512BW-NEXT:    retq
924   %shuffle = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 16, i32 17, i32 18, i32 19, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
925   %mask.cast = bitcast i16 %mask to <16 x i1>
926   %res = select <16 x i1> %mask.cast, <16 x i32> %shuffle, <16 x i32> %passthru
927   ret <16 x i32> %res
930 define <16 x i32> @mask_shuffle_v4i32_v16i32_00_01_02_03_00_01_02_03_00_01_02_03_00_01_02_03(<4 x i32> %a) {
931 ; ALL-LABEL: mask_shuffle_v4i32_v16i32_00_01_02_03_00_01_02_03_00_01_02_03_00_01_02_03:
932 ; ALL:       # %bb.0:
933 ; ALL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
934 ; ALL-NEXT:    vshufi64x2 {{.*#+}} zmm0 = zmm0[0,1,0,1,0,1,0,1]
935 ; ALL-NEXT:    retq
936   %res = shufflevector <4 x i32> %a, <4 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
937   ret <16 x i32> %res
940 define <16 x float> @mask_shuffle_v4f32_v16f32_00_01_02_03_00_01_02_03_00_01_02_03_00_01_02_03(<4 x float> %a) {
941 ; ALL-LABEL: mask_shuffle_v4f32_v16f32_00_01_02_03_00_01_02_03_00_01_02_03_00_01_02_03:
942 ; ALL:       # %bb.0:
943 ; ALL-NEXT:    # kill: def $xmm0 killed $xmm0 def $zmm0
944 ; ALL-NEXT:    vshuff64x2 {{.*#+}} zmm0 = zmm0[0,1,0,1,0,1,0,1]
945 ; ALL-NEXT:    retq
946   %res = shufflevector <4 x float> %a, <4 x float> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3, i32 0, i32 1, i32 2, i32 3>
947   ret <16 x float> %res
950 %struct.foo = type { [4 x double], [3 x [4 x double]], [4 x double] }
952 ; This test previously hung in shuffle combining. https://github.com/ispc/ispc/issues/1864
953 define void @ispc_1864(ptr %arg) {
954 ; ALL-LABEL: ispc_1864:
955 ; ALL:       # %bb.0: # %bb
956 ; ALL-NEXT:    pushq %rbp
957 ; ALL-NEXT:    .cfi_def_cfa_offset 16
958 ; ALL-NEXT:    .cfi_offset %rbp, -16
959 ; ALL-NEXT:    movq %rsp, %rbp
960 ; ALL-NEXT:    .cfi_def_cfa_register %rbp
961 ; ALL-NEXT:    andq $-64, %rsp
962 ; ALL-NEXT:    subq $4864, %rsp # imm = 0x1300
963 ; ALL-NEXT:    vbroadcastss {{.*#+}} ymm0 = [-5.0E+0,-5.0E+0,-5.0E+0,-5.0E+0,-5.0E+0,-5.0E+0,-5.0E+0,-5.0E+0]
964 ; ALL-NEXT:    vmulps 32(%rdi), %ymm0, %ymm0
965 ; ALL-NEXT:    vcvtps2pd %ymm0, %zmm0
966 ; ALL-NEXT:    vshuff64x2 {{.*#+}} zmm0 = zmm0[2,3,4,5,4,5,6,7]
967 ; ALL-NEXT:    vmovapd %ymm0, {{[0-9]+}}(%rsp)
968 ; ALL-NEXT:    movq %rbp, %rsp
969 ; ALL-NEXT:    popq %rbp
970 ; ALL-NEXT:    .cfi_def_cfa %rsp, 8
971 ; ALL-NEXT:    vzeroupper
972 ; ALL-NEXT:    retq
974   %tmp = alloca [30 x %struct.foo], align 64
975   %tmp1 = load <16 x float>, ptr %arg, align 4
976   %tmp2 = fmul <16 x float> %tmp1, <float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00, float -5.000000e+00>
977   %tmp3 = fpext <16 x float> %tmp2 to <16 x double>
978   %tmp4 = getelementptr inbounds [30 x %struct.foo], ptr %tmp, i64 0, i64 3, i32 2, i64 0
979   %tmp5 = extractelement <16 x double> %tmp3, i32 10
980   store double %tmp5, ptr %tmp4, align 32
981   %tmp6 = getelementptr inbounds [30 x %struct.foo], ptr %tmp, i64 0, i64 3, i32 2, i64 1
982   %tmp7 = extractelement <16 x double> %tmp3, i32 11
983   store double %tmp7, ptr %tmp6, align 8
984   %tmp8 = getelementptr inbounds [30 x %struct.foo], ptr %tmp, i64 0, i64 3, i32 2, i64 2
985   %tmp9 = extractelement <16 x double> %tmp3, i32 12
986   store double %tmp9, ptr %tmp8, align 16
987   %tmp10 = getelementptr inbounds [30 x %struct.foo], ptr %tmp, i64 0, i64 3, i32 2, i64 3
988   %tmp11 = extractelement <16 x double> %tmp3, i32 13
989   store double %tmp11, ptr %tmp10, align 8
990   ret void