23ddc3a6c1dcb08663f0c6706ba8c1003b9723b4
[oota-llvm.git] / test / CodeGen / X86 / avx512-shuffle.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl --show-mc-encoding| FileCheck %s
2 ; CHECK: LCP
3 ; CHECK: .long 2
4 ; CHECK: .long 5
5 ; CHECK: .long 0
6 ; CHECK: .long 0
7 ; CHECK: .long 7
8 ; CHECK: .long 0
9 ; CHECK: .long 10
10 ; CHECK: .long 1
11 ; CHECK: .long 0
12 ; CHECK: .long 5
13 ; CHECK: .long 0
14 ; CHECK: .long 4
15 ; CHECK: .long 7
16 ; CHECK: .long 0
17 ; CHECK: .long 10
18 ; CHECK: .long 1
19 ; CHECK-LABEL: test1:
20 ; CHECK: vpermps
21 ; CHECK: ret
22 define <16 x float> @test1(<16 x float> %a) nounwind {
23   %c = shufflevector <16 x float> %a, <16 x float> undef, <16 x i32> <i32 2, i32 5, i32 undef, i32 undef, i32 7, i32 undef, i32 10, i32 1,  i32 0, i32 5, i32 undef, i32 4, i32 7, i32 undef, i32 10, i32 1>
24   ret <16 x float> %c
25 }
26
27 ; CHECK-LABEL: test2:
28 ; CHECK: vpermd
29 ; CHECK: ret
30 define <16 x i32> @test2(<16 x i32> %a) nounwind {
31   %c = shufflevector <16 x i32> %a, <16 x i32> undef, <16 x i32> <i32 2, i32 5, i32 undef, i32 undef, i32 7, i32 undef, i32 10, i32 1,  i32 0, i32 5, i32 undef, i32 4, i32 7, i32 undef, i32 10, i32 1>
32   ret <16 x i32> %c
33 }
34
35 ; CHECK-LABEL: test3:
36 ; CHECK: vpermq
37 ; CHECK: ret
38 define <8 x i64> @test3(<8 x i64> %a) nounwind {
39   %c = shufflevector <8 x i64> %a, <8 x i64> undef, <8 x i32> <i32 2, i32 5, i32 1, i32 undef, i32 7, i32 undef, i32 3, i32 1>
40   ret <8 x i64> %c
41 }
42
43 ; CHECK-LABEL: test4:
44 ; CHECK: vpermpd
45 ; CHECK: ret
46 define <8 x double> @test4(<8 x double> %a) nounwind {
47   %c = shufflevector <8 x double> %a, <8 x double> undef, <8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
48   ret <8 x double> %c
49 }
50
51 ; CHECK-LABEL: test5:
52 ; CHECK: vpermt2pd
53 ; CHECK: ret
54 define <8 x double> @test5(<8 x double> %a, <8 x double> %b) nounwind {
55   %c = shufflevector <8 x double> %a, <8 x double> %b, <8 x i32> <i32 2, i32 8, i32 0, i32 1, i32 6, i32 10, i32 4, i32 5>
56   ret <8 x double> %c
57 }
58
59 ; CHECK-LABEL: test6:
60 ; CHECK: vpermq $30
61 ; CHECK: ret
62 define <8 x i64> @test6(<8 x i64> %a) nounwind {
63   %c = shufflevector <8 x i64> %a, <8 x i64> undef, <8 x i32> <i32 2, i32 3, i32 1, i32 0, i32 6, i32 7, i32 5, i32 4>
64   ret <8 x i64> %c
65 }
66
67 ; CHECK-LABEL: test7:
68 ; CHECK: vpermt2q
69 ; CHECK: ret
70 define <8 x i64> @test7(<8 x i64> %a, <8 x i64> %b) nounwind {
71   %c = shufflevector <8 x i64> %a, <8 x i64> %b, <8 x i32> <i32 2, i32 8, i32 0, i32 1, i32 6, i32 10, i32 4, i32 5>
72   ret <8 x i64> %c
73 }
74
75 ; CHECK-LABEL: test8:
76 ; CHECK: vpermt2d
77 ; CHECK: ret
78 define <16 x i32> @test8(<16 x i32> %a, <16 x i32> %b) nounwind {
79   %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>
80   ret <16 x i32> %c
81 }
82
83 ; CHECK-LABEL: test9:
84 ; CHECK: vpermt2ps
85 ; CHECK: ret
86 define <16 x float> @test9(<16 x float> %a, <16 x float> %b) nounwind {
87   %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>
88   ret <16 x float> %c
89 }
90
91 ; CHECK-LABEL: test10:
92 ; CHECK: vpermt2ps (
93 ; CHECK: ret
94 define <16 x float> @test10(<16 x float> %a, <16 x float>* %b) nounwind {
95   %c = load <16 x float>* %b
96   %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>
97   ret <16 x float> %d
98 }
99
100 ; CHECK-LABEL: test11:
101 ; CHECK: vpermt2d 
102 ; CHECK: ret
103 define <16 x i32> @test11(<16 x i32> %a, <16 x i32>* %b) nounwind {
104   %c = load <16 x i32>* %b
105   %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>
106   ret <16 x i32> %d
107 }
108
109 ; CHECK-LABEL: test12
110 ; CHECK: vmovlhps {{.*}}## encoding: [0x62
111 ; CHECK: ret
112 define <4 x i32> @test12(<4 x i32> %a, <4 x i32> %b) nounwind {
113   %c = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
114   ret <4 x i32> %c
115 }
116
117 ; CHECK-LABEL: test13
118 ; CHECK: vpermilps $-79, %zmm
119 ; CHECK: ret
120 define <16 x float> @test13(<16 x float> %a) {
121  %b = shufflevector <16 x float> %a, <16 x float> undef, <16 x i32><i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
122  ret <16 x float> %b
123 }
124
125 ; CHECK-LABEL: test14
126 ; CHECK: vpermilpd $-53, %zmm
127 ; CHECK: ret
128 define <8 x double> @test14(<8 x double> %a) {
129  %b = shufflevector <8 x double> %a, <8 x double> undef, <8 x i32><i32 1, i32 1, i32 2, i32 3, i32 4, i32 4, i32 7, i32 7>
130  ret <8 x double> %b
131 }
132
133 ; CHECK-LABEL: test15
134 ; CHECK: vpshufd $-79, %zmm
135 ; CHECK: ret
136 define <16 x i32> @test15(<16 x i32> %a) {
137  %b = shufflevector <16 x i32> %a, <16 x i32> undef, <16 x i32><i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
138  ret <16 x i32> %b
139 }
140 ; CHECK-LABEL: test16
141 ; CHECK: valignq $2, %zmm0, %zmm1
142 ; CHECK: ret
143 define <8 x double> @test16(<8 x double> %a, <8 x double> %b) nounwind {
144   %c = shufflevector <8 x double> %a, <8 x double> %b, <8 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9>
145   ret <8 x double> %c
146 }
147
148 ; CHECK-LABEL: test17
149 ; CHECK: vshufpd $19, %zmm1, %zmm0
150 ; CHECK: ret
151 define <8 x double> @test17(<8 x double> %a, <8 x double> %b) nounwind {
152   %c = shufflevector <8 x double> %a, <8 x double> %b, <8 x i32> <i32 1, i32 9, i32 2, i32 10, i32 5, i32 undef, i32 undef, i32 undef>
153   ret <8 x double> %c
154 }
155
156 ; CHECK-LABEL: test18
157 ; CHECK: vpunpckhdq %zmm
158 ; CHECK: ret
159 define <16 x i32> @test18(<16 x i32> %a, <16 x i32> %c) {
160  %b = shufflevector <16 x i32> %a, <16 x i32> %c, <16 x i32><i32 2, i32 10, i32 3, i32 11, i32 6, i32 14, i32 7, i32 15, i32 18, i32 26, i32 19, i32 27, i32 22, i32 30, i32 23, i32 31>
161  ret <16 x i32> %b
162 }
163
164 ; CHECK-LABEL: test19
165 ; CHECK: vpunpckldq %zmm
166 ; CHECK: ret
167 define <16 x i32> @test19(<16 x i32> %a, <16 x i32> %c) {
168  %b = shufflevector <16 x i32> %a, <16 x i32> %c, <16 x i32><i32 0, i32 8, i32 1, i32 9, i32 4, i32 12, i32 5, i32 13, i32 16, i32 24, i32 17, i32 25, i32 20, i32 28, i32 21, i32 29>
169  ret <16 x i32> %b
170 }
171
172 ; CHECK-LABEL: test20
173 ; CHECK: vpunpckhqdq  %zmm
174 ; CHECK: ret
175 define <8 x i64> @test20(<8 x i64> %a, <8 x i64> %c) {
176  %b = shufflevector <8 x i64> %a, <8 x i64> %c, <8 x i32><i32 1, i32 5, i32 3, i32 7, i32 9, i32 13, i32 11, i32 15>
177  ret <8 x i64> %b
178 }
179
180 ; CHECK-LABEL: test21
181 ; CHECK: vunpcklps %zmm
182 ; CHECK: ret
183 define <16 x float> @test21(<16 x float> %a, <16 x float> %c) {
184  %b = shufflevector <16 x float> %a, <16 x float> %c, <16 x i32><i32 0, i32 8, i32 1, i32 9, i32 4, i32 12, i32 5, i32 13, i32 16, i32 24, i32 17, i32 25, i32 20, i32 28, i32 21, i32 29>
185  ret <16 x float> %b
186 }
187
188 ; CHECK-LABEL: test22
189 ; CHECK: vmovhlps {{.*}}## encoding: [0x62
190 ; CHECK: ret
191 define <4 x i32> @test22(<4 x i32> %a, <4 x i32> %b) nounwind {
192   %c = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 2, i32 3, i32 6, i32 7>
193   ret <4 x i32> %c
194 }
195
196 ; CHECK-LABEL: @test23
197 ; CHECK: vshufps $-112, %zmm
198 ; CHECK: ret
199 define <16 x float> @test23(<16 x float> %a, <16 x float> %c) {
200  %b = shufflevector <16 x float> %a, <16 x float> %c, <16 x i32><i32 0, i32 0, i32 17, i32 18, i32 4, i32 4, i32 21, i32 22, i32 8, i32 8, i32 25, i32 26, i32 12, i32 12, i32 29, i32 30>
201  ret <16 x float> %b
202 }
203
204 ; CHECK-LABEL: @test24
205 ; CHECK: vpermt2d
206 ; CHECK: ret
207 define <16 x i32> @test24(<16 x i32> %a, <16 x i32> %b) nounwind {
208   %c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 19, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
209   ret <16 x i32> %c
210 }
211
212 ; CHECK-LABEL: @test25
213 ; CHECK: vshufps  $52
214 ; CHECK: ret
215 define <16 x i32> @test25(<16 x i32> %a, <16 x i32> %b) nounwind {
216   %c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 19, i32 undef, i32 4, i32 5, i32 23, i32 undef, i32 8, i32 9, i32 27, i32 undef, i32 12, i32 13, i32 undef, i32 undef>
217   ret <16 x i32> %c
218 }
219
220 ; CHECK-LABEL: @test26
221 ; CHECK: vmovshdup
222 ; CHECK: ret
223 define <16 x i32> @test26(<16 x i32> %a) nounwind {
224   %c = shufflevector <16 x i32> %a, <16 x i32> undef, <16 x i32> <i32 1, i32 1, i32 3, i32 3, i32 5, i32 5, i32 7, i32 undef, i32 9, i32 9, i32 undef, i32 11, i32 13, i32 undef, i32 undef, i32 undef>
225   ret <16 x i32> %c
226 }
227
228 ; CHECK-LABEL: @test27
229 ; CHECK: ret
230 define <16 x i32> @test27(<4 x i32>%a) {
231  %res = shufflevector <4 x i32> %a, <4 x i32> undef, <16 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
232  ret <16 x i32> %res
233 }
234
235 ; CHECK-LABEL: @test28
236 ; CHECK: vinserti64x4 $1
237 ; CHECK: ret
238 define <16 x i32> @test28(<16 x i32>%x, <16 x i32>%y) {
239  %res = shufflevector <16 x i32>%x, <16 x i32>%y, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7,
240                                                               i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
241  ret <16 x i32> %res
242 }
243
244 ; CHECK-LABEL: @test29
245 ; CHECK: vinserti64x4 $0
246 ; CHECK: ret
247 define <16 x i32> @test29(<16 x i32>%x, <16 x i32>%y) {
248  %res = shufflevector <16 x i32>%x, <16 x i32>%y, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23,
249                                                               i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
250  ret <16 x i32> %res
251 }
252