1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.2 | FileCheck %s --check-prefixes=SSE
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX12,AVX1
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=AVX12,AVX2
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f | FileCheck %s --check-prefix=AVX512 --check-prefix=AVX512F
6 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512f,+avx512bw | FileCheck %s --check-prefix=AVX512 --check-prefix=AVX512BW
8 define i8 @v8i64(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c, <8 x i64> %d) {
11 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm8
12 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm9
13 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm10
14 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm11
15 ; SSE-NEXT: pcmpgtq %xmm7, %xmm3
16 ; SSE-NEXT: pshufd {{.*#+}} xmm3 = xmm3[0,2,2,3]
17 ; SSE-NEXT: pshuflw {{.*#+}} xmm3 = xmm3[0,1,0,2,4,5,6,7]
18 ; SSE-NEXT: pcmpgtq %xmm6, %xmm2
19 ; SSE-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]
20 ; SSE-NEXT: pshuflw {{.*#+}} xmm2 = xmm2[0,1,0,2,4,5,6,7]
21 ; SSE-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
22 ; SSE-NEXT: pcmpgtq %xmm5, %xmm1
23 ; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
24 ; SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,2,2,3,4,5,6,7]
25 ; SSE-NEXT: pcmpgtq %xmm4, %xmm0
26 ; SSE-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
27 ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7]
28 ; SSE-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
29 ; SSE-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm2[4,5,6,7]
30 ; SSE-NEXT: pcmpgtq {{[0-9]+}}(%rsp), %xmm11
31 ; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm11[0,2,2,3]
32 ; SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,1,0,2,4,5,6,7]
33 ; SSE-NEXT: pcmpgtq {{[0-9]+}}(%rsp), %xmm10
34 ; SSE-NEXT: pshufd {{.*#+}} xmm2 = xmm10[0,2,2,3]
35 ; SSE-NEXT: pshuflw {{.*#+}} xmm2 = xmm2[0,1,0,2,4,5,6,7]
36 ; SSE-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
37 ; SSE-NEXT: pcmpgtq {{[0-9]+}}(%rsp), %xmm9
38 ; SSE-NEXT: pshufd {{.*#+}} xmm1 = xmm9[0,2,2,3]
39 ; SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm1[0,2,2,3,4,5,6,7]
40 ; SSE-NEXT: pcmpgtq {{[0-9]+}}(%rsp), %xmm8
41 ; SSE-NEXT: pshufd {{.*#+}} xmm3 = xmm8[0,2,2,3]
42 ; SSE-NEXT: pshuflw {{.*#+}} xmm3 = xmm3[0,2,2,3,4,5,6,7]
43 ; SSE-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
44 ; SSE-NEXT: pblendw {{.*#+}} xmm3 = xmm3[0,1,2,3],xmm2[4,5,6,7]
45 ; SSE-NEXT: pand %xmm0, %xmm3
46 ; SSE-NEXT: packsswb %xmm0, %xmm3
47 ; SSE-NEXT: pmovmskb %xmm3, %eax
48 ; SSE-NEXT: # kill: def $al killed $al killed $eax
53 ; AVX1-NEXT: vextractf128 $1, %ymm7, %xmm8
54 ; AVX1-NEXT: vextractf128 $1, %ymm5, %xmm9
55 ; AVX1-NEXT: vpcmpgtq %xmm8, %xmm9, %xmm8
56 ; AVX1-NEXT: vpcmpgtq %xmm7, %xmm5, %xmm5
57 ; AVX1-NEXT: vpackssdw %xmm8, %xmm5, %xmm8
58 ; AVX1-NEXT: vextractf128 $1, %ymm6, %xmm7
59 ; AVX1-NEXT: vextractf128 $1, %ymm4, %xmm5
60 ; AVX1-NEXT: vpcmpgtq %xmm7, %xmm5, %xmm5
61 ; AVX1-NEXT: vpcmpgtq %xmm6, %xmm4, %xmm4
62 ; AVX1-NEXT: vpackssdw %xmm5, %xmm4, %xmm4
63 ; AVX1-NEXT: vinsertf128 $1, %xmm8, %ymm4, %ymm4
64 ; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm5
65 ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm6
66 ; AVX1-NEXT: vpcmpgtq %xmm5, %xmm6, %xmm5
67 ; AVX1-NEXT: vpcmpgtq %xmm3, %xmm1, %xmm1
68 ; AVX1-NEXT: vpackssdw %xmm5, %xmm1, %xmm1
69 ; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3
70 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm5
71 ; AVX1-NEXT: vpcmpgtq %xmm3, %xmm5, %xmm3
72 ; AVX1-NEXT: vpcmpgtq %xmm2, %xmm0, %xmm0
73 ; AVX1-NEXT: vpackssdw %xmm3, %xmm0, %xmm0
74 ; AVX1-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
75 ; AVX1-NEXT: vandps %ymm4, %ymm0, %ymm0
76 ; AVX1-NEXT: vmovmskps %ymm0, %eax
77 ; AVX1-NEXT: # kill: def $al killed $al killed $eax
78 ; AVX1-NEXT: vzeroupper
83 ; AVX2-NEXT: vpcmpgtq %ymm7, %ymm5, %ymm5
84 ; AVX2-NEXT: vpcmpgtq %ymm6, %ymm4, %ymm4
85 ; AVX2-NEXT: vpackssdw %ymm5, %ymm4, %ymm4
86 ; AVX2-NEXT: vpcmpgtq %ymm3, %ymm1, %ymm1
87 ; AVX2-NEXT: vpcmpgtq %ymm2, %ymm0, %ymm0
88 ; AVX2-NEXT: vpackssdw %ymm1, %ymm0, %ymm0
89 ; AVX2-NEXT: vpand %ymm4, %ymm0, %ymm0
90 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3]
91 ; AVX2-NEXT: vmovmskps %ymm0, %eax
92 ; AVX2-NEXT: # kill: def $al killed $al killed $eax
93 ; AVX2-NEXT: vzeroupper
96 ; AVX512F-LABEL: v8i64:
98 ; AVX512F-NEXT: vpcmpgtq %zmm1, %zmm0, %k1
99 ; AVX512F-NEXT: vpcmpgtq %zmm3, %zmm2, %k0 {%k1}
100 ; AVX512F-NEXT: kmovw %k0, %eax
101 ; AVX512F-NEXT: # kill: def $al killed $al killed $eax
102 ; AVX512F-NEXT: vzeroupper
105 ; AVX512BW-LABEL: v8i64:
107 ; AVX512BW-NEXT: vpcmpgtq %zmm1, %zmm0, %k1
108 ; AVX512BW-NEXT: vpcmpgtq %zmm3, %zmm2, %k0 {%k1}
109 ; AVX512BW-NEXT: kmovd %k0, %eax
110 ; AVX512BW-NEXT: # kill: def $al killed $al killed $eax
111 ; AVX512BW-NEXT: vzeroupper
112 ; AVX512BW-NEXT: retq
113 %x0 = icmp sgt <8 x i64> %a, %b
114 %x1 = icmp sgt <8 x i64> %c, %d
115 %y = and <8 x i1> %x0, %x1
116 %res = bitcast <8 x i1> %y to i8
120 define i8 @v8f64(<8 x double> %a, <8 x double> %b, <8 x double> %c, <8 x double> %d) {
123 ; SSE-NEXT: movapd {{[0-9]+}}(%rsp), %xmm8
124 ; SSE-NEXT: movapd {{[0-9]+}}(%rsp), %xmm9
125 ; SSE-NEXT: movapd {{[0-9]+}}(%rsp), %xmm10
126 ; SSE-NEXT: movapd {{[0-9]+}}(%rsp), %xmm11
127 ; SSE-NEXT: cmpltpd %xmm3, %xmm7
128 ; SSE-NEXT: shufps {{.*#+}} xmm7 = xmm7[0,2,2,3]
129 ; SSE-NEXT: pshuflw {{.*#+}} xmm3 = xmm7[0,1,0,2,4,5,6,7]
130 ; SSE-NEXT: cmpltpd %xmm2, %xmm6
131 ; SSE-NEXT: shufps {{.*#+}} xmm6 = xmm6[0,2,2,3]
132 ; SSE-NEXT: pshuflw {{.*#+}} xmm2 = xmm6[0,1,0,2,4,5,6,7]
133 ; SSE-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
134 ; SSE-NEXT: cmpltpd %xmm1, %xmm5
135 ; SSE-NEXT: shufps {{.*#+}} xmm5 = xmm5[0,2,2,3]
136 ; SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm5[0,2,2,3,4,5,6,7]
137 ; SSE-NEXT: cmpltpd %xmm0, %xmm4
138 ; SSE-NEXT: shufps {{.*#+}} xmm4 = xmm4[0,2,2,3]
139 ; SSE-NEXT: pshuflw {{.*#+}} xmm0 = xmm4[0,2,2,3,4,5,6,7]
140 ; SSE-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
141 ; SSE-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm2[4,5,6,7]
142 ; SSE-NEXT: cmpltpd {{[0-9]+}}(%rsp), %xmm11
143 ; SSE-NEXT: shufps {{.*#+}} xmm11 = xmm11[0,2,2,3]
144 ; SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm11[0,1,0,2,4,5,6,7]
145 ; SSE-NEXT: cmpltpd {{[0-9]+}}(%rsp), %xmm10
146 ; SSE-NEXT: shufps {{.*#+}} xmm10 = xmm10[0,2,2,3]
147 ; SSE-NEXT: pshuflw {{.*#+}} xmm2 = xmm10[0,1,0,2,4,5,6,7]
148 ; SSE-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
149 ; SSE-NEXT: cmpltpd {{[0-9]+}}(%rsp), %xmm9
150 ; SSE-NEXT: shufps {{.*#+}} xmm9 = xmm9[0,2,2,3]
151 ; SSE-NEXT: pshuflw {{.*#+}} xmm1 = xmm9[0,2,2,3,4,5,6,7]
152 ; SSE-NEXT: cmpltpd {{[0-9]+}}(%rsp), %xmm8
153 ; SSE-NEXT: shufps {{.*#+}} xmm8 = xmm8[0,2,2,3]
154 ; SSE-NEXT: pshuflw {{.*#+}} xmm3 = xmm8[0,2,2,3,4,5,6,7]
155 ; SSE-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
156 ; SSE-NEXT: pblendw {{.*#+}} xmm3 = xmm3[0,1,2,3],xmm2[4,5,6,7]
157 ; SSE-NEXT: pand %xmm0, %xmm3
158 ; SSE-NEXT: packsswb %xmm0, %xmm3
159 ; SSE-NEXT: pmovmskb %xmm3, %eax
160 ; SSE-NEXT: # kill: def $al killed $al killed $eax
165 ; AVX1-NEXT: vcmpltpd %ymm5, %ymm7, %ymm5
166 ; AVX1-NEXT: vextractf128 $1, %ymm5, %xmm7
167 ; AVX1-NEXT: vpackssdw %xmm7, %xmm5, %xmm5
168 ; AVX1-NEXT: vcmpltpd %ymm4, %ymm6, %ymm4
169 ; AVX1-NEXT: vextractf128 $1, %ymm4, %xmm6
170 ; AVX1-NEXT: vpackssdw %xmm6, %xmm4, %xmm4
171 ; AVX1-NEXT: vinsertf128 $1, %xmm5, %ymm4, %ymm4
172 ; AVX1-NEXT: vcmpltpd %ymm1, %ymm3, %ymm1
173 ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm3
174 ; AVX1-NEXT: vpackssdw %xmm3, %xmm1, %xmm1
175 ; AVX1-NEXT: vcmpltpd %ymm0, %ymm2, %ymm0
176 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm2
177 ; AVX1-NEXT: vpackssdw %xmm2, %xmm0, %xmm0
178 ; AVX1-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
179 ; AVX1-NEXT: vandps %ymm4, %ymm0, %ymm0
180 ; AVX1-NEXT: vmovmskps %ymm0, %eax
181 ; AVX1-NEXT: # kill: def $al killed $al killed $eax
182 ; AVX1-NEXT: vzeroupper
187 ; AVX2-NEXT: vcmpltpd %ymm5, %ymm7, %ymm5
188 ; AVX2-NEXT: vcmpltpd %ymm4, %ymm6, %ymm4
189 ; AVX2-NEXT: vpackssdw %ymm5, %ymm4, %ymm4
190 ; AVX2-NEXT: vcmpltpd %ymm1, %ymm3, %ymm1
191 ; AVX2-NEXT: vcmpltpd %ymm0, %ymm2, %ymm0
192 ; AVX2-NEXT: vpackssdw %ymm1, %ymm0, %ymm0
193 ; AVX2-NEXT: vpand %ymm4, %ymm0, %ymm0
194 ; AVX2-NEXT: vpermq {{.*#+}} ymm0 = ymm0[0,2,1,3]
195 ; AVX2-NEXT: vmovmskps %ymm0, %eax
196 ; AVX2-NEXT: # kill: def $al killed $al killed $eax
197 ; AVX2-NEXT: vzeroupper
200 ; AVX512F-LABEL: v8f64:
202 ; AVX512F-NEXT: vcmpltpd %zmm0, %zmm1, %k1
203 ; AVX512F-NEXT: vcmpltpd %zmm2, %zmm3, %k0 {%k1}
204 ; AVX512F-NEXT: kmovw %k0, %eax
205 ; AVX512F-NEXT: # kill: def $al killed $al killed $eax
206 ; AVX512F-NEXT: vzeroupper
209 ; AVX512BW-LABEL: v8f64:
211 ; AVX512BW-NEXT: vcmpltpd %zmm0, %zmm1, %k1
212 ; AVX512BW-NEXT: vcmpltpd %zmm2, %zmm3, %k0 {%k1}
213 ; AVX512BW-NEXT: kmovd %k0, %eax
214 ; AVX512BW-NEXT: # kill: def $al killed $al killed $eax
215 ; AVX512BW-NEXT: vzeroupper
216 ; AVX512BW-NEXT: retq
217 %x0 = fcmp ogt <8 x double> %a, %b
218 %x1 = fcmp ogt <8 x double> %c, %d
219 %y = and <8 x i1> %x0, %x1
220 %res = bitcast <8 x i1> %y to i8
224 define i32 @v32i16(<32 x i16> %a, <32 x i16> %b, <32 x i16> %c, <32 x i16> %d) {
227 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm8
228 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm9
229 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm10
230 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm11
231 ; SSE-NEXT: pcmpgtw %xmm5, %xmm1
232 ; SSE-NEXT: pcmpgtw %xmm4, %xmm0
233 ; SSE-NEXT: packsswb %xmm1, %xmm0
234 ; SSE-NEXT: pcmpgtw %xmm7, %xmm3
235 ; SSE-NEXT: pcmpgtw %xmm6, %xmm2
236 ; SSE-NEXT: packsswb %xmm3, %xmm2
237 ; SSE-NEXT: pcmpgtw {{[0-9]+}}(%rsp), %xmm11
238 ; SSE-NEXT: pcmpgtw {{[0-9]+}}(%rsp), %xmm10
239 ; SSE-NEXT: packsswb %xmm11, %xmm10
240 ; SSE-NEXT: pand %xmm0, %xmm10
241 ; SSE-NEXT: pcmpgtw {{[0-9]+}}(%rsp), %xmm9
242 ; SSE-NEXT: pcmpgtw {{[0-9]+}}(%rsp), %xmm8
243 ; SSE-NEXT: packsswb %xmm9, %xmm8
244 ; SSE-NEXT: pand %xmm2, %xmm8
245 ; SSE-NEXT: pmovmskb %xmm10, %ecx
246 ; SSE-NEXT: pmovmskb %xmm8, %eax
247 ; SSE-NEXT: shll $16, %eax
248 ; SSE-NEXT: orl %ecx, %eax
251 ; AVX1-LABEL: v32i16:
253 ; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm8
254 ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm9
255 ; AVX1-NEXT: vpcmpgtw %xmm8, %xmm9, %xmm8
256 ; AVX1-NEXT: vpcmpgtw %xmm3, %xmm1, %xmm1
257 ; AVX1-NEXT: vpacksswb %xmm8, %xmm1, %xmm8
258 ; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3
259 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
260 ; AVX1-NEXT: vpcmpgtw %xmm3, %xmm1, %xmm1
261 ; AVX1-NEXT: vpcmpgtw %xmm2, %xmm0, %xmm0
262 ; AVX1-NEXT: vpacksswb %xmm1, %xmm0, %xmm0
263 ; AVX1-NEXT: vextractf128 $1, %ymm7, %xmm1
264 ; AVX1-NEXT: vextractf128 $1, %ymm5, %xmm2
265 ; AVX1-NEXT: vpcmpgtw %xmm1, %xmm2, %xmm1
266 ; AVX1-NEXT: vpcmpgtw %xmm7, %xmm5, %xmm2
267 ; AVX1-NEXT: vpacksswb %xmm1, %xmm2, %xmm1
268 ; AVX1-NEXT: vpand %xmm1, %xmm8, %xmm1
269 ; AVX1-NEXT: vextractf128 $1, %ymm6, %xmm2
270 ; AVX1-NEXT: vextractf128 $1, %ymm4, %xmm3
271 ; AVX1-NEXT: vpcmpgtw %xmm2, %xmm3, %xmm2
272 ; AVX1-NEXT: vpcmpgtw %xmm6, %xmm4, %xmm3
273 ; AVX1-NEXT: vpacksswb %xmm2, %xmm3, %xmm2
274 ; AVX1-NEXT: vpand %xmm2, %xmm0, %xmm0
275 ; AVX1-NEXT: vpmovmskb %xmm0, %ecx
276 ; AVX1-NEXT: vpmovmskb %xmm1, %eax
277 ; AVX1-NEXT: shll $16, %eax
278 ; AVX1-NEXT: orl %ecx, %eax
279 ; AVX1-NEXT: vzeroupper
282 ; AVX2-LABEL: v32i16:
284 ; AVX2-NEXT: vpcmpgtw %ymm3, %ymm1, %ymm1
285 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm3
286 ; AVX2-NEXT: vpacksswb %xmm3, %xmm1, %xmm1
287 ; AVX2-NEXT: vpcmpgtw %ymm2, %ymm0, %ymm0
288 ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2
289 ; AVX2-NEXT: vpacksswb %xmm2, %xmm0, %xmm0
290 ; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm0, %ymm0
291 ; AVX2-NEXT: vpcmpgtw %ymm7, %ymm5, %ymm1
292 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm2
293 ; AVX2-NEXT: vpacksswb %xmm2, %xmm1, %xmm1
294 ; AVX2-NEXT: vpcmpgtw %ymm6, %ymm4, %ymm2
295 ; AVX2-NEXT: vextracti128 $1, %ymm2, %xmm3
296 ; AVX2-NEXT: vpacksswb %xmm3, %xmm2, %xmm2
297 ; AVX2-NEXT: vinserti128 $1, %xmm1, %ymm2, %ymm1
298 ; AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
299 ; AVX2-NEXT: vpmovmskb %ymm0, %eax
300 ; AVX2-NEXT: vzeroupper
303 ; AVX512F-LABEL: v32i16:
305 ; AVX512F-NEXT: vextracti64x4 $1, %zmm3, %ymm4
306 ; AVX512F-NEXT: vextracti64x4 $1, %zmm2, %ymm5
307 ; AVX512F-NEXT: vpcmpgtw %ymm4, %ymm5, %ymm4
308 ; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm5
309 ; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm6
310 ; AVX512F-NEXT: vpcmpgtw %ymm5, %ymm6, %ymm5
311 ; AVX512F-NEXT: vpand %ymm4, %ymm5, %ymm4
312 ; AVX512F-NEXT: vpcmpgtw %ymm1, %ymm0, %ymm0
313 ; AVX512F-NEXT: vpcmpgtw %ymm3, %ymm2, %ymm1
314 ; AVX512F-NEXT: vpand %ymm1, %ymm0, %ymm0
315 ; AVX512F-NEXT: vpmovsxwd %ymm0, %zmm0
316 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k0
317 ; AVX512F-NEXT: kmovw %k0, %ecx
318 ; AVX512F-NEXT: vpmovsxwd %ymm4, %zmm0
319 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k0
320 ; AVX512F-NEXT: kmovw %k0, %eax
321 ; AVX512F-NEXT: shll $16, %eax
322 ; AVX512F-NEXT: orl %ecx, %eax
323 ; AVX512F-NEXT: vzeroupper
326 ; AVX512BW-LABEL: v32i16:
328 ; AVX512BW-NEXT: vpcmpgtw %zmm1, %zmm0, %k1
329 ; AVX512BW-NEXT: vpcmpgtw %zmm3, %zmm2, %k0 {%k1}
330 ; AVX512BW-NEXT: kmovd %k0, %eax
331 ; AVX512BW-NEXT: vzeroupper
332 ; AVX512BW-NEXT: retq
333 %x0 = icmp sgt <32 x i16> %a, %b
334 %x1 = icmp sgt <32 x i16> %c, %d
335 %y = and <32 x i1> %x0, %x1
336 %res = bitcast <32 x i1> %y to i32
340 define i16 @v16i32(<16 x i32> %a, <16 x i32> %b, <16 x i32> %c, <16 x i32> %d) {
343 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm8
344 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm10
345 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm9
346 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm11
347 ; SSE-NEXT: pcmpgtd %xmm7, %xmm3
348 ; SSE-NEXT: movdqa {{.*#+}} xmm7 = <u,u,u,u,0,4,8,12,u,u,u,u,u,u,u,u>
349 ; SSE-NEXT: pshufb %xmm7, %xmm3
350 ; SSE-NEXT: pcmpgtd %xmm6, %xmm2
351 ; SSE-NEXT: pshufb %xmm7, %xmm2
352 ; SSE-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
353 ; SSE-NEXT: pcmpgtd %xmm5, %xmm1
354 ; SSE-NEXT: movdqa {{.*#+}} xmm3 = <0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u>
355 ; SSE-NEXT: pshufb %xmm3, %xmm1
356 ; SSE-NEXT: pcmpgtd %xmm4, %xmm0
357 ; SSE-NEXT: pshufb %xmm3, %xmm0
358 ; SSE-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
359 ; SSE-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm2[4,5,6,7]
360 ; SSE-NEXT: pcmpgtd {{[0-9]+}}(%rsp), %xmm11
361 ; SSE-NEXT: pshufb %xmm7, %xmm11
362 ; SSE-NEXT: pcmpgtd {{[0-9]+}}(%rsp), %xmm9
363 ; SSE-NEXT: pshufb %xmm7, %xmm9
364 ; SSE-NEXT: punpckldq {{.*#+}} xmm9 = xmm9[0],xmm11[0],xmm9[1],xmm11[1]
365 ; SSE-NEXT: pcmpgtd {{[0-9]+}}(%rsp), %xmm10
366 ; SSE-NEXT: pshufb %xmm3, %xmm10
367 ; SSE-NEXT: pcmpgtd {{[0-9]+}}(%rsp), %xmm8
368 ; SSE-NEXT: pshufb %xmm3, %xmm8
369 ; SSE-NEXT: punpckldq {{.*#+}} xmm8 = xmm8[0],xmm10[0],xmm8[1],xmm10[1]
370 ; SSE-NEXT: pblendw {{.*#+}} xmm8 = xmm8[0,1,2,3],xmm9[4,5,6,7]
371 ; SSE-NEXT: pand %xmm0, %xmm8
372 ; SSE-NEXT: pmovmskb %xmm8, %eax
373 ; SSE-NEXT: # kill: def $ax killed $ax killed $eax
376 ; AVX1-LABEL: v16i32:
378 ; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm8
379 ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm9
380 ; AVX1-NEXT: vpcmpgtd %xmm8, %xmm9, %xmm8
381 ; AVX1-NEXT: vpcmpgtd %xmm3, %xmm1, %xmm1
382 ; AVX1-NEXT: vpackssdw %xmm8, %xmm1, %xmm8
383 ; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3
384 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
385 ; AVX1-NEXT: vpcmpgtd %xmm3, %xmm1, %xmm1
386 ; AVX1-NEXT: vpcmpgtd %xmm2, %xmm0, %xmm0
387 ; AVX1-NEXT: vpackssdw %xmm1, %xmm0, %xmm0
388 ; AVX1-NEXT: vpacksswb %xmm8, %xmm0, %xmm0
389 ; AVX1-NEXT: vextractf128 $1, %ymm7, %xmm1
390 ; AVX1-NEXT: vextractf128 $1, %ymm5, %xmm2
391 ; AVX1-NEXT: vpcmpgtd %xmm1, %xmm2, %xmm1
392 ; AVX1-NEXT: vpcmpgtd %xmm7, %xmm5, %xmm2
393 ; AVX1-NEXT: vpackssdw %xmm1, %xmm2, %xmm1
394 ; AVX1-NEXT: vextractf128 $1, %ymm6, %xmm2
395 ; AVX1-NEXT: vextractf128 $1, %ymm4, %xmm3
396 ; AVX1-NEXT: vpcmpgtd %xmm2, %xmm3, %xmm2
397 ; AVX1-NEXT: vpcmpgtd %xmm6, %xmm4, %xmm3
398 ; AVX1-NEXT: vpackssdw %xmm2, %xmm3, %xmm2
399 ; AVX1-NEXT: vpacksswb %xmm1, %xmm2, %xmm1
400 ; AVX1-NEXT: vpand %xmm1, %xmm0, %xmm0
401 ; AVX1-NEXT: vpmovmskb %xmm0, %eax
402 ; AVX1-NEXT: # kill: def $ax killed $ax killed $eax
403 ; AVX1-NEXT: vzeroupper
406 ; AVX2-LABEL: v16i32:
408 ; AVX2-NEXT: vpcmpgtd %ymm3, %ymm1, %ymm1
409 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm3
410 ; AVX2-NEXT: vpackssdw %xmm3, %xmm1, %xmm1
411 ; AVX2-NEXT: vpcmpgtd %ymm2, %ymm0, %ymm0
412 ; AVX2-NEXT: vextracti128 $1, %ymm0, %xmm2
413 ; AVX2-NEXT: vpackssdw %xmm2, %xmm0, %xmm0
414 ; AVX2-NEXT: vpacksswb %xmm1, %xmm0, %xmm0
415 ; AVX2-NEXT: vpcmpgtd %ymm7, %ymm5, %ymm1
416 ; AVX2-NEXT: vextracti128 $1, %ymm1, %xmm2
417 ; AVX2-NEXT: vpackssdw %xmm2, %xmm1, %xmm1
418 ; AVX2-NEXT: vpcmpgtd %ymm6, %ymm4, %ymm2
419 ; AVX2-NEXT: vextracti128 $1, %ymm2, %xmm3
420 ; AVX2-NEXT: vpackssdw %xmm3, %xmm2, %xmm2
421 ; AVX2-NEXT: vpacksswb %xmm1, %xmm2, %xmm1
422 ; AVX2-NEXT: vpand %xmm1, %xmm0, %xmm0
423 ; AVX2-NEXT: vpmovmskb %xmm0, %eax
424 ; AVX2-NEXT: # kill: def $ax killed $ax killed $eax
425 ; AVX2-NEXT: vzeroupper
428 ; AVX512F-LABEL: v16i32:
430 ; AVX512F-NEXT: vpcmpgtd %zmm1, %zmm0, %k1
431 ; AVX512F-NEXT: vpcmpgtd %zmm3, %zmm2, %k0 {%k1}
432 ; AVX512F-NEXT: kmovw %k0, %eax
433 ; AVX512F-NEXT: # kill: def $ax killed $ax killed $eax
434 ; AVX512F-NEXT: vzeroupper
437 ; AVX512BW-LABEL: v16i32:
439 ; AVX512BW-NEXT: vpcmpgtd %zmm1, %zmm0, %k1
440 ; AVX512BW-NEXT: vpcmpgtd %zmm3, %zmm2, %k0 {%k1}
441 ; AVX512BW-NEXT: kmovd %k0, %eax
442 ; AVX512BW-NEXT: # kill: def $ax killed $ax killed $eax
443 ; AVX512BW-NEXT: vzeroupper
444 ; AVX512BW-NEXT: retq
445 %x0 = icmp sgt <16 x i32> %a, %b
446 %x1 = icmp sgt <16 x i32> %c, %d
447 %y = and <16 x i1> %x0, %x1
448 %res = bitcast <16 x i1> %y to i16
452 define i16 @v16f32(<16 x float> %a, <16 x float> %b, <16 x float> %c, <16 x float> %d) {
455 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm8
456 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm10
457 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm9
458 ; SSE-NEXT: movaps {{[0-9]+}}(%rsp), %xmm11
459 ; SSE-NEXT: cmpltps %xmm3, %xmm7
460 ; SSE-NEXT: movdqa {{.*#+}} xmm3 = <u,u,u,u,0,4,8,12,u,u,u,u,u,u,u,u>
461 ; SSE-NEXT: pshufb %xmm3, %xmm7
462 ; SSE-NEXT: cmpltps %xmm2, %xmm6
463 ; SSE-NEXT: pshufb %xmm3, %xmm6
464 ; SSE-NEXT: punpckldq {{.*#+}} xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
465 ; SSE-NEXT: cmpltps %xmm1, %xmm5
466 ; SSE-NEXT: movdqa {{.*#+}} xmm1 = <0,4,8,12,u,u,u,u,u,u,u,u,u,u,u,u>
467 ; SSE-NEXT: pshufb %xmm1, %xmm5
468 ; SSE-NEXT: cmpltps %xmm0, %xmm4
469 ; SSE-NEXT: pshufb %xmm1, %xmm4
470 ; SSE-NEXT: punpckldq {{.*#+}} xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
471 ; SSE-NEXT: pblendw {{.*#+}} xmm4 = xmm4[0,1,2,3],xmm6[4,5,6,7]
472 ; SSE-NEXT: cmpltps {{[0-9]+}}(%rsp), %xmm11
473 ; SSE-NEXT: pshufb %xmm3, %xmm11
474 ; SSE-NEXT: cmpltps {{[0-9]+}}(%rsp), %xmm9
475 ; SSE-NEXT: pshufb %xmm3, %xmm9
476 ; SSE-NEXT: punpckldq {{.*#+}} xmm9 = xmm9[0],xmm11[0],xmm9[1],xmm11[1]
477 ; SSE-NEXT: cmpltps {{[0-9]+}}(%rsp), %xmm10
478 ; SSE-NEXT: pshufb %xmm1, %xmm10
479 ; SSE-NEXT: cmpltps {{[0-9]+}}(%rsp), %xmm8
480 ; SSE-NEXT: pshufb %xmm1, %xmm8
481 ; SSE-NEXT: punpckldq {{.*#+}} xmm8 = xmm8[0],xmm10[0],xmm8[1],xmm10[1]
482 ; SSE-NEXT: pblendw {{.*#+}} xmm8 = xmm8[0,1,2,3],xmm9[4,5,6,7]
483 ; SSE-NEXT: pand %xmm4, %xmm8
484 ; SSE-NEXT: pmovmskb %xmm8, %eax
485 ; SSE-NEXT: # kill: def $ax killed $ax killed $eax
488 ; AVX12-LABEL: v16f32:
490 ; AVX12-NEXT: vcmpltps %ymm1, %ymm3, %ymm1
491 ; AVX12-NEXT: vextractf128 $1, %ymm1, %xmm3
492 ; AVX12-NEXT: vpackssdw %xmm3, %xmm1, %xmm1
493 ; AVX12-NEXT: vcmpltps %ymm0, %ymm2, %ymm0
494 ; AVX12-NEXT: vextractf128 $1, %ymm0, %xmm2
495 ; AVX12-NEXT: vpackssdw %xmm2, %xmm0, %xmm0
496 ; AVX12-NEXT: vpacksswb %xmm1, %xmm0, %xmm0
497 ; AVX12-NEXT: vcmpltps %ymm5, %ymm7, %ymm1
498 ; AVX12-NEXT: vextractf128 $1, %ymm1, %xmm2
499 ; AVX12-NEXT: vpackssdw %xmm2, %xmm1, %xmm1
500 ; AVX12-NEXT: vcmpltps %ymm4, %ymm6, %ymm2
501 ; AVX12-NEXT: vextractf128 $1, %ymm2, %xmm3
502 ; AVX12-NEXT: vpackssdw %xmm3, %xmm2, %xmm2
503 ; AVX12-NEXT: vpacksswb %xmm1, %xmm2, %xmm1
504 ; AVX12-NEXT: vpand %xmm1, %xmm0, %xmm0
505 ; AVX12-NEXT: vpmovmskb %xmm0, %eax
506 ; AVX12-NEXT: # kill: def $ax killed $ax killed $eax
507 ; AVX12-NEXT: vzeroupper
510 ; AVX512F-LABEL: v16f32:
512 ; AVX512F-NEXT: vcmpltps %zmm0, %zmm1, %k1
513 ; AVX512F-NEXT: vcmpltps %zmm2, %zmm3, %k0 {%k1}
514 ; AVX512F-NEXT: kmovw %k0, %eax
515 ; AVX512F-NEXT: # kill: def $ax killed $ax killed $eax
516 ; AVX512F-NEXT: vzeroupper
519 ; AVX512BW-LABEL: v16f32:
521 ; AVX512BW-NEXT: vcmpltps %zmm0, %zmm1, %k1
522 ; AVX512BW-NEXT: vcmpltps %zmm2, %zmm3, %k0 {%k1}
523 ; AVX512BW-NEXT: kmovd %k0, %eax
524 ; AVX512BW-NEXT: # kill: def $ax killed $ax killed $eax
525 ; AVX512BW-NEXT: vzeroupper
526 ; AVX512BW-NEXT: retq
527 %x0 = fcmp ogt <16 x float> %a, %b
528 %x1 = fcmp ogt <16 x float> %c, %d
529 %y = and <16 x i1> %x0, %x1
530 %res = bitcast <16 x i1> %y to i16
534 define i64 @v64i8(<64 x i8> %a, <64 x i8> %b, <64 x i8> %c, <64 x i8> %d) {
537 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm10
538 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm11
539 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm8
540 ; SSE-NEXT: movdqa {{[0-9]+}}(%rsp), %xmm9
541 ; SSE-NEXT: pcmpgtb %xmm7, %xmm3
542 ; SSE-NEXT: pcmpgtb %xmm6, %xmm2
543 ; SSE-NEXT: pcmpgtb %xmm5, %xmm1
544 ; SSE-NEXT: pcmpgtb %xmm4, %xmm0
545 ; SSE-NEXT: pcmpgtb {{[0-9]+}}(%rsp), %xmm9
546 ; SSE-NEXT: pand %xmm3, %xmm9
547 ; SSE-NEXT: pcmpgtb {{[0-9]+}}(%rsp), %xmm8
548 ; SSE-NEXT: pand %xmm2, %xmm8
549 ; SSE-NEXT: pcmpgtb {{[0-9]+}}(%rsp), %xmm11
550 ; SSE-NEXT: pand %xmm1, %xmm11
551 ; SSE-NEXT: pcmpgtb {{[0-9]+}}(%rsp), %xmm10
552 ; SSE-NEXT: pand %xmm0, %xmm10
553 ; SSE-NEXT: pmovmskb %xmm10, %eax
554 ; SSE-NEXT: pmovmskb %xmm11, %ecx
555 ; SSE-NEXT: shll $16, %ecx
556 ; SSE-NEXT: orl %eax, %ecx
557 ; SSE-NEXT: pmovmskb %xmm8, %edx
558 ; SSE-NEXT: pmovmskb %xmm9, %eax
559 ; SSE-NEXT: shll $16, %eax
560 ; SSE-NEXT: orl %edx, %eax
561 ; SSE-NEXT: shlq $32, %rax
562 ; SSE-NEXT: orq %rcx, %rax
567 ; AVX1-NEXT: vextractf128 $1, %ymm3, %xmm8
568 ; AVX1-NEXT: vextractf128 $1, %ymm1, %xmm9
569 ; AVX1-NEXT: vpcmpgtb %xmm8, %xmm9, %xmm8
570 ; AVX1-NEXT: vpcmpgtb %xmm3, %xmm1, %xmm9
571 ; AVX1-NEXT: vextractf128 $1, %ymm2, %xmm3
572 ; AVX1-NEXT: vextractf128 $1, %ymm0, %xmm1
573 ; AVX1-NEXT: vpcmpgtb %xmm3, %xmm1, %xmm1
574 ; AVX1-NEXT: vpcmpgtb %xmm2, %xmm0, %xmm0
575 ; AVX1-NEXT: vextractf128 $1, %ymm7, %xmm2
576 ; AVX1-NEXT: vextractf128 $1, %ymm5, %xmm3
577 ; AVX1-NEXT: vpcmpgtb %xmm2, %xmm3, %xmm2
578 ; AVX1-NEXT: vpand %xmm2, %xmm8, %xmm2
579 ; AVX1-NEXT: vpcmpgtb %xmm7, %xmm5, %xmm3
580 ; AVX1-NEXT: vpand %xmm3, %xmm9, %xmm3
581 ; AVX1-NEXT: vextractf128 $1, %ymm6, %xmm5
582 ; AVX1-NEXT: vextractf128 $1, %ymm4, %xmm7
583 ; AVX1-NEXT: vpcmpgtb %xmm5, %xmm7, %xmm5
584 ; AVX1-NEXT: vpand %xmm5, %xmm1, %xmm1
585 ; AVX1-NEXT: vpcmpgtb %xmm6, %xmm4, %xmm4
586 ; AVX1-NEXT: vpand %xmm4, %xmm0, %xmm0
587 ; AVX1-NEXT: vpmovmskb %xmm0, %eax
588 ; AVX1-NEXT: vpmovmskb %xmm1, %ecx
589 ; AVX1-NEXT: shll $16, %ecx
590 ; AVX1-NEXT: orl %eax, %ecx
591 ; AVX1-NEXT: vpmovmskb %xmm3, %edx
592 ; AVX1-NEXT: vpmovmskb %xmm2, %eax
593 ; AVX1-NEXT: shll $16, %eax
594 ; AVX1-NEXT: orl %edx, %eax
595 ; AVX1-NEXT: shlq $32, %rax
596 ; AVX1-NEXT: orq %rcx, %rax
597 ; AVX1-NEXT: vzeroupper
602 ; AVX2-NEXT: vpcmpgtb %ymm3, %ymm1, %ymm1
603 ; AVX2-NEXT: vpcmpgtb %ymm2, %ymm0, %ymm0
604 ; AVX2-NEXT: vpcmpgtb %ymm7, %ymm5, %ymm2
605 ; AVX2-NEXT: vpand %ymm2, %ymm1, %ymm1
606 ; AVX2-NEXT: vpcmpgtb %ymm6, %ymm4, %ymm2
607 ; AVX2-NEXT: vpand %ymm2, %ymm0, %ymm0
608 ; AVX2-NEXT: vpmovmskb %ymm0, %ecx
609 ; AVX2-NEXT: vpmovmskb %ymm1, %eax
610 ; AVX2-NEXT: shlq $32, %rax
611 ; AVX2-NEXT: orq %rcx, %rax
612 ; AVX2-NEXT: vzeroupper
615 ; AVX512F-LABEL: v64i8:
617 ; AVX512F-NEXT: vextracti64x4 $1, %zmm3, %ymm4
618 ; AVX512F-NEXT: vextracti64x4 $1, %zmm2, %ymm5
619 ; AVX512F-NEXT: vpcmpgtb %ymm4, %ymm5, %ymm4
620 ; AVX512F-NEXT: vextracti64x4 $1, %zmm1, %ymm5
621 ; AVX512F-NEXT: vextracti64x4 $1, %zmm0, %ymm6
622 ; AVX512F-NEXT: vpcmpgtb %ymm5, %ymm6, %ymm5
623 ; AVX512F-NEXT: vextracti128 $1, %ymm5, %xmm6
624 ; AVX512F-NEXT: vpcmpgtb %ymm1, %ymm0, %ymm0
625 ; AVX512F-NEXT: vextracti128 $1, %ymm0, %xmm1
626 ; AVX512F-NEXT: vextracti128 $1, %ymm4, %xmm7
627 ; AVX512F-NEXT: vpand %xmm7, %xmm6, %xmm6
628 ; AVX512F-NEXT: vpcmpgtb %ymm3, %ymm2, %ymm2
629 ; AVX512F-NEXT: vextracti128 $1, %ymm2, %xmm3
630 ; AVX512F-NEXT: vpand %xmm3, %xmm1, %xmm1
631 ; AVX512F-NEXT: vpand %xmm2, %xmm0, %xmm0
632 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
633 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k0
634 ; AVX512F-NEXT: kmovw %k0, %eax
635 ; AVX512F-NEXT: vpmovsxbd %xmm1, %zmm0
636 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k0
637 ; AVX512F-NEXT: kmovw %k0, %ecx
638 ; AVX512F-NEXT: shll $16, %ecx
639 ; AVX512F-NEXT: orl %eax, %ecx
640 ; AVX512F-NEXT: vpand %xmm4, %xmm5, %xmm0
641 ; AVX512F-NEXT: vpmovsxbd %xmm0, %zmm0
642 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k0
643 ; AVX512F-NEXT: kmovw %k0, %edx
644 ; AVX512F-NEXT: vpmovsxbd %xmm6, %zmm0
645 ; AVX512F-NEXT: vptestmd %zmm0, %zmm0, %k0
646 ; AVX512F-NEXT: kmovw %k0, %eax
647 ; AVX512F-NEXT: shll $16, %eax
648 ; AVX512F-NEXT: orl %edx, %eax
649 ; AVX512F-NEXT: shlq $32, %rax
650 ; AVX512F-NEXT: orq %rcx, %rax
651 ; AVX512F-NEXT: vzeroupper
654 ; AVX512BW-LABEL: v64i8:
656 ; AVX512BW-NEXT: vpcmpgtb %zmm1, %zmm0, %k1
657 ; AVX512BW-NEXT: vpcmpgtb %zmm3, %zmm2, %k0 {%k1}
658 ; AVX512BW-NEXT: kmovq %k0, %rax
659 ; AVX512BW-NEXT: vzeroupper
660 ; AVX512BW-NEXT: retq
661 %x0 = icmp sgt <64 x i8> %a, %b
662 %x1 = icmp sgt <64 x i8> %c, %d
663 %y = and <64 x i1> %x0, %x1
664 %res = bitcast <64 x i1> %y to i64