1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=X32
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefix=X64
5 define i32 @knownbits_mask_extract_sext(<8 x i16> %a0) nounwind {
6 ; X32-LABEL: knownbits_mask_extract_sext:
8 ; X32-NEXT: vmovd %xmm0, %eax
9 ; X32-NEXT: andl $15, %eax
12 ; X64-LABEL: knownbits_mask_extract_sext:
14 ; X64-NEXT: vmovd %xmm0, %eax
15 ; X64-NEXT: andl $15, %eax
17 %1 = and <8 x i16> %a0, <i16 15, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
18 %2 = extractelement <8 x i16> %1, i32 0
19 %3 = sext i16 %2 to i32
23 define float @knownbits_mask_extract_uitofp(<2 x i64> %a0) nounwind {
24 ; X32-LABEL: knownbits_mask_extract_uitofp:
26 ; X32-NEXT: pushl %eax
27 ; X32-NEXT: vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
28 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
29 ; X32-NEXT: vmovss %xmm0, (%esp)
30 ; X32-NEXT: flds (%esp)
34 ; X64-LABEL: knownbits_mask_extract_uitofp:
36 ; X64-NEXT: vpmovzxwq {{.*#+}} xmm0 = xmm0[0],zero,zero,zero,xmm0[1],zero,zero,zero
37 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
39 %1 = and <2 x i64> %a0, <i64 65535, i64 -1>
40 %2 = extractelement <2 x i64> %1, i32 0
41 %3 = uitofp i64 %2 to float
45 define <4 x float> @knownbits_insert_uitofp(<4 x i32> %a0, i16 %a1, i16 %a2) nounwind {
46 ; X32-LABEL: knownbits_insert_uitofp:
48 ; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
49 ; X32-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
50 ; X32-NEXT: vmovd %ecx, %xmm0
51 ; X32-NEXT: vpinsrd $2, %eax, %xmm0, %xmm0
52 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,2,2]
53 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
56 ; X64-LABEL: knownbits_insert_uitofp:
58 ; X64-NEXT: movzwl %di, %eax
59 ; X64-NEXT: movzwl %si, %ecx
60 ; X64-NEXT: vmovd %eax, %xmm0
61 ; X64-NEXT: vpinsrd $2, %ecx, %xmm0, %xmm0
62 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,2,2]
63 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
65 %1 = zext i16 %a1 to i32
66 %2 = zext i16 %a2 to i32
67 %3 = insertelement <4 x i32> %a0, i32 %1, i32 0
68 %4 = insertelement <4 x i32> %3, i32 %2, i32 2
69 %5 = shufflevector <4 x i32> %4, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
70 %6 = uitofp <4 x i32> %5 to <4 x float>
74 define <4 x i32> @knownbits_mask_shuffle_sext(<8 x i16> %a0) nounwind {
75 ; X32-LABEL: knownbits_mask_shuffle_sext:
77 ; X32-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
78 ; X32-NEXT: vpxor %xmm1, %xmm1, %xmm1
79 ; X32-NEXT: vpunpckhwd {{.*#+}} xmm0 = xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
82 ; X64-LABEL: knownbits_mask_shuffle_sext:
84 ; X64-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
85 ; X64-NEXT: vpxor %xmm1, %xmm1, %xmm1
86 ; X64-NEXT: vpunpckhwd {{.*#+}} xmm0 = xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
88 %1 = and <8 x i16> %a0, <i16 -1, i16 -1, i16 -1, i16 -1, i16 15, i16 15, i16 15, i16 15>
89 %2 = shufflevector <8 x i16> %1, <8 x i16> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
90 %3 = sext <4 x i16> %2 to <4 x i32>
94 define <4 x i32> @knownbits_mask_shuffle_shuffle_sext(<8 x i16> %a0) nounwind {
95 ; X32-LABEL: knownbits_mask_shuffle_shuffle_sext:
97 ; X32-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
98 ; X32-NEXT: vpxor %xmm1, %xmm1, %xmm1
99 ; X32-NEXT: vpunpckhwd {{.*#+}} xmm0 = xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
102 ; X64-LABEL: knownbits_mask_shuffle_shuffle_sext:
104 ; X64-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
105 ; X64-NEXT: vpxor %xmm1, %xmm1, %xmm1
106 ; X64-NEXT: vpunpckhwd {{.*#+}} xmm0 = xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
108 %1 = and <8 x i16> %a0, <i16 -1, i16 -1, i16 -1, i16 -1, i16 15, i16 15, i16 15, i16 15>
109 %2 = shufflevector <8 x i16> %1, <8 x i16> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef>
110 %3 = shufflevector <8 x i16> %2, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
111 %4 = sext <4 x i16> %3 to <4 x i32>
115 define <4 x i32> @knownbits_mask_shuffle_shuffle_undef_sext(<8 x i16> %a0) nounwind {
116 ; X32-LABEL: knownbits_mask_shuffle_shuffle_undef_sext:
118 ; X32-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
119 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
120 ; X32-NEXT: vpmovsxwd %xmm0, %xmm0
123 ; X64-LABEL: knownbits_mask_shuffle_shuffle_undef_sext:
125 ; X64-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
126 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
127 ; X64-NEXT: vpmovsxwd %xmm0, %xmm0
129 %1 = and <8 x i16> %a0, <i16 -1, i16 -1, i16 -1, i16 -1, i16 15, i16 15, i16 15, i16 15>
130 %2 = shufflevector <8 x i16> %1, <8 x i16> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
131 %3 = shufflevector <8 x i16> %2, <8 x i16> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
132 %4 = sext <4 x i16> %3 to <4 x i32>
136 define <4 x float> @knownbits_mask_shuffle_uitofp(<4 x i32> %a0) nounwind {
137 ; X32-LABEL: knownbits_mask_shuffle_uitofp:
139 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
140 ; X32-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
141 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
144 ; X64-LABEL: knownbits_mask_shuffle_uitofp:
146 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
147 ; X64-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
148 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
150 %1 = and <4 x i32> %a0, <i32 -1, i32 -1, i32 255, i32 4085>
151 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
152 %3 = uitofp <4 x i32> %2 to <4 x float>
156 define <4 x float> @knownbits_mask_or_shuffle_uitofp(<4 x i32> %a0) nounwind {
157 ; X32-LABEL: knownbits_mask_or_shuffle_uitofp:
159 ; X32-NEXT: vmovaps {{.*#+}} xmm0 = [6.5535E+4,6.5535E+4,6.5535E+4,6.5535E+4]
162 ; X64-LABEL: knownbits_mask_or_shuffle_uitofp:
164 ; X64-NEXT: vmovaps {{.*#+}} xmm0 = [6.5535E+4,6.5535E+4,6.5535E+4,6.5535E+4]
166 %1 = and <4 x i32> %a0, <i32 -1, i32 -1, i32 255, i32 4085>
167 %2 = or <4 x i32> %1, <i32 65535, i32 65535, i32 65535, i32 65535>
168 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
169 %4 = uitofp <4 x i32> %3 to <4 x float>
173 define <4 x float> @knownbits_mask_xor_shuffle_uitofp(<4 x i32> %a0) nounwind {
174 ; X32-LABEL: knownbits_mask_xor_shuffle_uitofp:
176 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
177 ; X32-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
178 ; X32-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
179 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
182 ; X64-LABEL: knownbits_mask_xor_shuffle_uitofp:
184 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
185 ; X64-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
186 ; X64-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[2,2,3,3]
187 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
189 %1 = and <4 x i32> %a0, <i32 -1, i32 -1, i32 255, i32 4085>
190 %2 = xor <4 x i32> %1, <i32 65535, i32 65535, i32 65535, i32 65535>
191 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 2, i32 2, i32 3, i32 3>
192 %4 = uitofp <4 x i32> %3 to <4 x float>
196 define <4 x i32> @knownbits_mask_shl_shuffle_lshr(<4 x i32> %a0) nounwind {
197 ; X32-LABEL: knownbits_mask_shl_shuffle_lshr:
199 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
202 ; X64-LABEL: knownbits_mask_shl_shuffle_lshr:
204 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
206 %1 = and <4 x i32> %a0, <i32 -65536, i32 -7, i32 -7, i32 -65536>
207 %2 = shl <4 x i32> %1, <i32 17, i32 17, i32 17, i32 17>
208 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
209 %4 = lshr <4 x i32> %3, <i32 15, i32 15, i32 15, i32 15>
213 define <4 x i32> @knownbits_mask_ashr_shuffle_lshr(<4 x i32> %a0) nounwind {
214 ; X32-LABEL: knownbits_mask_ashr_shuffle_lshr:
216 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
219 ; X64-LABEL: knownbits_mask_ashr_shuffle_lshr:
221 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
223 %1 = and <4 x i32> %a0, <i32 131071, i32 -1, i32 -1, i32 131071>
224 %2 = ashr <4 x i32> %1, <i32 15, i32 15, i32 15, i32 15>
225 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
226 %4 = lshr <4 x i32> %3, <i32 30, i32 30, i32 30, i32 30>
230 define <4 x i32> @knownbits_mask_mul_shuffle_shl(<4 x i32> %a0, <4 x i32> %a1) nounwind {
231 ; X32-LABEL: knownbits_mask_mul_shuffle_shl:
233 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
236 ; X64-LABEL: knownbits_mask_mul_shuffle_shl:
238 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
240 %1 = and <4 x i32> %a0, <i32 -65536, i32 -7, i32 -7, i32 -65536>
241 %2 = mul <4 x i32> %a1, %1
242 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
243 %4 = shl <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
247 define <4 x i32> @knownbits_mask_trunc_shuffle_shl(<4 x i64> %a0) nounwind {
248 ; X32-LABEL: knownbits_mask_trunc_shuffle_shl:
250 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
253 ; X64-LABEL: knownbits_mask_trunc_shuffle_shl:
255 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
257 %1 = and <4 x i64> %a0, <i64 -65536, i64 -7, i64 7, i64 -65536>
258 %2 = trunc <4 x i64> %1 to <4 x i32>
259 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
260 %4 = shl <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
264 define <4 x i32> @knownbits_mask_add_shuffle_lshr(<4 x i32> %a0, <4 x i32> %a1) nounwind {
265 ; X32-LABEL: knownbits_mask_add_shuffle_lshr:
267 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
270 ; X64-LABEL: knownbits_mask_add_shuffle_lshr:
272 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
274 %1 = and <4 x i32> %a0, <i32 32767, i32 -1, i32 -1, i32 32767>
275 %2 = and <4 x i32> %a1, <i32 32767, i32 -1, i32 -1, i32 32767>
276 %3 = add <4 x i32> %1, %2
277 %4 = shufflevector <4 x i32> %3, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
278 %5 = lshr <4 x i32> %4, <i32 17, i32 17, i32 17, i32 17>
282 define <4 x i32> @knownbits_mask_sub_shuffle_lshr(<4 x i32> %a0) nounwind {
283 ; X32-LABEL: knownbits_mask_sub_shuffle_lshr:
285 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
288 ; X64-LABEL: knownbits_mask_sub_shuffle_lshr:
290 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
292 %1 = and <4 x i32> %a0, <i32 15, i32 -1, i32 -1, i32 15>
293 %2 = sub <4 x i32> <i32 255, i32 255, i32 255, i32 255>, %1
294 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
295 %4 = lshr <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
299 define <4 x i32> @knownbits_mask_udiv_shuffle_lshr(<4 x i32> %a0, <4 x i32> %a1) nounwind {
300 ; X32-LABEL: knownbits_mask_udiv_shuffle_lshr:
302 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
305 ; X64-LABEL: knownbits_mask_udiv_shuffle_lshr:
307 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
309 %1 = and <4 x i32> %a0, <i32 32767, i32 -1, i32 -1, i32 32767>
310 %2 = udiv <4 x i32> %1, %a1
311 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
312 %4 = lshr <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
316 define <4 x i32> @knownbits_urem_lshr(<4 x i32> %a0) nounwind {
317 ; X32-LABEL: knownbits_urem_lshr:
319 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
322 ; X64-LABEL: knownbits_urem_lshr:
324 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
326 %1 = urem <4 x i32> %a0, <i32 16, i32 16, i32 16, i32 16>
327 %2 = lshr <4 x i32> %1, <i32 22, i32 22, i32 22, i32 22>
331 define <4 x i32> @knownbits_mask_urem_shuffle_lshr(<4 x i32> %a0, <4 x i32> %a1) nounwind {
332 ; X32-LABEL: knownbits_mask_urem_shuffle_lshr:
334 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
337 ; X64-LABEL: knownbits_mask_urem_shuffle_lshr:
339 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
341 %1 = and <4 x i32> %a0, <i32 32767, i32 -1, i32 -1, i32 32767>
342 %2 = and <4 x i32> %a1, <i32 32767, i32 -1, i32 -1, i32 32767>
343 %3 = urem <4 x i32> %1, %2
344 %4 = shufflevector <4 x i32> %3, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
345 %5 = lshr <4 x i32> %4, <i32 22, i32 22, i32 22, i32 22>
349 define <4 x i32> @knownbits_mask_srem_shuffle_lshr(<4 x i32> %a0) nounwind {
350 ; X32-LABEL: knownbits_mask_srem_shuffle_lshr:
352 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
355 ; X64-LABEL: knownbits_mask_srem_shuffle_lshr:
357 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
359 %1 = and <4 x i32> %a0, <i32 -32768, i32 -1, i32 -1, i32 -32768>
360 %2 = srem <4 x i32> %1, <i32 16, i32 16, i32 16, i32 16>
361 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
362 %4 = lshr <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
366 define <4 x i32> @knownbits_mask_bswap_shuffle_shl(<4 x i32> %a0) nounwind {
367 ; X32-LABEL: knownbits_mask_bswap_shuffle_shl:
369 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
372 ; X64-LABEL: knownbits_mask_bswap_shuffle_shl:
374 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
376 %1 = and <4 x i32> %a0, <i32 32767, i32 -1, i32 -1, i32 32767>
377 %2 = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %1)
378 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
379 %4 = shl <4 x i32> %3, <i32 22, i32 22, i32 22, i32 22>
382 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
384 define <8 x float> @knownbits_mask_concat_uitofp(<4 x i32> %a0, <4 x i32> %a1) nounwind {
385 ; X32-LABEL: knownbits_mask_concat_uitofp:
387 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
388 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1, %xmm1
389 ; X32-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,0,2]
390 ; X32-NEXT: vpermilps {{.*#+}} xmm1 = xmm1[1,3,1,3]
391 ; X32-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
392 ; X32-NEXT: vcvtdq2ps %ymm0, %ymm0
395 ; X64-LABEL: knownbits_mask_concat_uitofp:
397 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
398 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
399 ; X64-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,2,0,2]
400 ; X64-NEXT: vpermilps {{.*#+}} xmm1 = xmm1[1,3,1,3]
401 ; X64-NEXT: vinsertf128 $1, %xmm1, %ymm0, %ymm0
402 ; X64-NEXT: vcvtdq2ps %ymm0, %ymm0
404 %1 = and <4 x i32> %a0, <i32 131071, i32 -1, i32 131071, i32 -1>
405 %2 = and <4 x i32> %a1, <i32 -1, i32 131071, i32 -1, i32 131071>
406 %3 = shufflevector <4 x i32> %1, <4 x i32> %2, <8 x i32> <i32 0, i32 2, i32 0, i32 2, i32 5, i32 7, i32 5, i32 7>
407 %4 = uitofp <8 x i32> %3 to <8 x float>
411 define <4 x float> @knownbits_lshr_bitcast_shuffle_uitofp(<2 x i64> %a0, <4 x i32> %a1) nounwind {
412 ; X32-LABEL: knownbits_lshr_bitcast_shuffle_uitofp:
414 ; X32-NEXT: vpsrlq $1, %xmm0, %xmm0
415 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
416 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
419 ; X64-LABEL: knownbits_lshr_bitcast_shuffle_uitofp:
421 ; X64-NEXT: vpsrlq $1, %xmm0, %xmm0
422 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
423 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
425 %1 = lshr <2 x i64> %a0, <i64 1, i64 1>
426 %2 = bitcast <2 x i64> %1 to <4 x i32>
427 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 3, i32 3>
428 %4 = uitofp <4 x i32> %3 to <4 x float>
432 define <4 x float> @knownbits_smax_smin_shuffle_uitofp(<4 x i32> %a0) {
433 ; X32-LABEL: knownbits_smax_smin_shuffle_uitofp:
435 ; X32-NEXT: vpminsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
436 ; X32-NEXT: vpmaxsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
437 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,3,3]
438 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
441 ; X64-LABEL: knownbits_smax_smin_shuffle_uitofp:
443 ; X64-NEXT: vpminsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
444 ; X64-NEXT: vpmaxsd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
445 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,3,3]
446 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
448 %1 = call <4 x i32> @llvm.smin.v4i32(<4 x i32> %a0, <4 x i32> <i32 0, i32 -65535, i32 -65535, i32 0>)
449 %2 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %1, <4 x i32> <i32 65535, i32 -1, i32 -1, i32 131071>)
450 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
451 %4 = uitofp <4 x i32> %3 to <4 x float>
454 declare <4 x i32> @llvm.smin.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
455 declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
457 define <4 x float> @knownbits_umin_shuffle_uitofp(<4 x i32> %a0) {
458 ; X32-LABEL: knownbits_umin_shuffle_uitofp:
460 ; X32-NEXT: vpminud {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
461 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,3,3]
462 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
465 ; X64-LABEL: knownbits_umin_shuffle_uitofp:
467 ; X64-NEXT: vpminud {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
468 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,3,3]
469 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
471 %1 = call <4 x i32> @llvm.umin.v4i32(<4 x i32> %a0, <4 x i32> <i32 65535, i32 -1, i32 -1, i32 262143>)
472 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
473 %3 = uitofp <4 x i32> %2 to <4 x float>
476 declare <4 x i32> @llvm.umin.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
478 define <4 x i32> @knownbits_umax_shuffle_ashr(<4 x i32> %a0) {
479 ; X32-LABEL: knownbits_umax_shuffle_ashr:
481 ; X32-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
484 ; X64-LABEL: knownbits_umax_shuffle_ashr:
486 ; X64-NEXT: vpcmpeqd %xmm0, %xmm0, %xmm0
488 %1 = call <4 x i32> @llvm.umax.v4i32(<4 x i32> %a0, <4 x i32> <i32 65535, i32 -1, i32 -1, i32 262143>)
489 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 2, i32 2>
490 %3 = ashr <4 x i32> %2, <i32 31, i32 31, i32 31, i32 31>
493 declare <4 x i32> @llvm.umax.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
495 define <4 x float> @knownbits_mask_umax_shuffle_uitofp(<4 x i32> %a0) {
496 ; X32-LABEL: knownbits_mask_umax_shuffle_uitofp:
498 ; X32-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
499 ; X32-NEXT: vpmaxud {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
500 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,3,3]
501 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
504 ; X64-LABEL: knownbits_mask_umax_shuffle_uitofp:
506 ; X64-NEXT: vpand {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
507 ; X64-NEXT: vpmaxud {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
508 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,0,3,3]
509 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
511 %1 = and <4 x i32> %a0, <i32 65535, i32 -1, i32 -1, i32 262143>
512 %2 = call <4 x i32> @llvm.umax.v4i32(<4 x i32> %1, <4 x i32> <i32 255, i32 -1, i32 -1, i32 1023>)
513 %3 = shufflevector <4 x i32> %2, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 3, i32 3>
514 %4 = uitofp <4 x i32> %3 to <4 x float>
518 define <4 x i32> @knownbits_mask_bitreverse_ashr(<4 x i32> %a0) {
519 ; X32-LABEL: knownbits_mask_bitreverse_ashr:
521 ; X32-NEXT: vxorps %xmm0, %xmm0, %xmm0
524 ; X64-LABEL: knownbits_mask_bitreverse_ashr:
526 ; X64-NEXT: vxorps %xmm0, %xmm0, %xmm0
528 %1 = and <4 x i32> %a0, <i32 -2, i32 -2, i32 -2, i32 -2>
529 %2 = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %1)
530 %3 = ashr <4 x i32> %2, <i32 31, i32 31, i32 31, i32 31>
533 declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32>) nounwind readnone
535 ; If we don't know that the input isn't INT_MIN we can't combine to sitofp
536 define <4 x float> @knownbits_abs_uitofp(<4 x i32> %a0) {
537 ; X32-LABEL: knownbits_abs_uitofp:
539 ; X32-NEXT: vpabsd %xmm0, %xmm0
540 ; X32-NEXT: vpblendw {{.*#+}} xmm1 = xmm0[0],mem[1],xmm0[2],mem[3],xmm0[4],mem[5],xmm0[6],mem[7]
541 ; X32-NEXT: vpsrld $16, %xmm0, %xmm0
542 ; X32-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0],mem[1],xmm0[2],mem[3],xmm0[4],mem[5],xmm0[6],mem[7]
543 ; X32-NEXT: vsubps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
544 ; X32-NEXT: vaddps %xmm0, %xmm1, %xmm0
547 ; X64-LABEL: knownbits_abs_uitofp:
549 ; X64-NEXT: vpabsd %xmm0, %xmm0
550 ; X64-NEXT: vpblendw {{.*#+}} xmm1 = xmm0[0],mem[1],xmm0[2],mem[3],xmm0[4],mem[5],xmm0[6],mem[7]
551 ; X64-NEXT: vpsrld $16, %xmm0, %xmm0
552 ; X64-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0],mem[1],xmm0[2],mem[3],xmm0[4],mem[5],xmm0[6],mem[7]
553 ; X64-NEXT: vsubps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
554 ; X64-NEXT: vaddps %xmm0, %xmm1, %xmm0
556 %1 = sub <4 x i32> zeroinitializer, %a0
557 %2 = icmp slt <4 x i32> %a0, zeroinitializer
558 %3 = select <4 x i1> %2, <4 x i32> %1, <4 x i32> %a0
559 %4 = uitofp <4 x i32> %3 to <4 x float>
563 define <4 x float> @knownbits_or_abs_uitofp(<4 x i32> %a0) {
564 ; X32-LABEL: knownbits_or_abs_uitofp:
566 ; X32-NEXT: vpor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %xmm0
567 ; X32-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,0,2]
568 ; X32-NEXT: vpabsd %xmm0, %xmm0
569 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
572 ; X64-LABEL: knownbits_or_abs_uitofp:
574 ; X64-NEXT: vpor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
575 ; X64-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[0,2,0,2]
576 ; X64-NEXT: vpabsd %xmm0, %xmm0
577 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
579 %1 = or <4 x i32> %a0, <i32 1, i32 0, i32 3, i32 0>
580 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 0, i32 2>
581 %3 = sub <4 x i32> zeroinitializer, %2
582 %4 = icmp slt <4 x i32> %2, zeroinitializer
583 %5 = select <4 x i1> %4, <4 x i32> %3, <4 x i32> %2
584 %6 = uitofp <4 x i32> %5 to <4 x float>
588 define <4 x float> @knownbits_and_select_shuffle_uitofp(<4 x i32> %a0, <4 x i32> %a1, <4 x i32> %a2, <4 x i32> %a3) nounwind {
589 ; X32-LABEL: knownbits_and_select_shuffle_uitofp:
591 ; X32-NEXT: pushl %ebp
592 ; X32-NEXT: movl %esp, %ebp
593 ; X32-NEXT: andl $-16, %esp
594 ; X32-NEXT: subl $16, %esp
595 ; X32-NEXT: vmovaps 8(%ebp), %xmm3
596 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm2, %xmm2
597 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm3, %xmm3
598 ; X32-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
599 ; X32-NEXT: vblendvps %xmm0, %xmm2, %xmm3, %xmm0
600 ; X32-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,2,2]
601 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
602 ; X32-NEXT: movl %ebp, %esp
603 ; X32-NEXT: popl %ebp
606 ; X64-LABEL: knownbits_and_select_shuffle_uitofp:
608 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2, %xmm2
609 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm3
610 ; X64-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
611 ; X64-NEXT: vblendvps %xmm0, %xmm2, %xmm3, %xmm0
612 ; X64-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,2,2]
613 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
615 %1 = and <4 x i32> %a2, <i32 65535, i32 -1, i32 255, i32 -1>
616 %2 = and <4 x i32> %a3, <i32 255, i32 -1, i32 65535, i32 -1>
617 %3 = icmp eq <4 x i32> %a0, %a1
618 %4 = select <4 x i1> %3, <4 x i32> %1, <4 x i32> %2
619 %5 = shufflevector <4 x i32> %4, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
620 %6 = uitofp <4 x i32> %5 to <4 x float>
624 define <4 x float> @knownbits_lshr_and_select_shuffle_uitofp(<4 x i32> %a0, <4 x i32> %a1, <4 x i32> %a2, <4 x i32> %a3) nounwind {
625 ; X32-LABEL: knownbits_lshr_and_select_shuffle_uitofp:
627 ; X32-NEXT: pushl %ebp
628 ; X32-NEXT: movl %esp, %ebp
629 ; X32-NEXT: andl $-16, %esp
630 ; X32-NEXT: subl $16, %esp
631 ; X32-NEXT: vmovaps 8(%ebp), %xmm3
632 ; X32-NEXT: vpsrld $5, %xmm2, %xmm2
633 ; X32-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm3, %xmm3
634 ; X32-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
635 ; X32-NEXT: vblendvps %xmm0, %xmm2, %xmm3, %xmm0
636 ; X32-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,2,2]
637 ; X32-NEXT: vcvtdq2ps %xmm0, %xmm0
638 ; X32-NEXT: movl %ebp, %esp
639 ; X32-NEXT: popl %ebp
642 ; X64-LABEL: knownbits_lshr_and_select_shuffle_uitofp:
644 ; X64-NEXT: vpsrld $5, %xmm2, %xmm2
645 ; X64-NEXT: vandps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3, %xmm3
646 ; X64-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0
647 ; X64-NEXT: vblendvps %xmm0, %xmm2, %xmm3, %xmm0
648 ; X64-NEXT: vpermilps {{.*#+}} xmm0 = xmm0[0,0,2,2]
649 ; X64-NEXT: vcvtdq2ps %xmm0, %xmm0
651 %1 = lshr <4 x i32> %a2, <i32 5, i32 1, i32 5, i32 1>
652 %2 = and <4 x i32> %a3, <i32 255, i32 -1, i32 65535, i32 -1>
653 %3 = icmp eq <4 x i32> %a0, %a1
654 %4 = select <4 x i1> %3, <4 x i32> %1, <4 x i32> %2
655 %5 = shufflevector <4 x i32> %4, <4 x i32> undef, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
656 %6 = uitofp <4 x i32> %5 to <4 x float>
660 define <2 x double> @knownbits_lshr_subvector_uitofp(<4 x i32> %x) {
661 ; X32-LABEL: knownbits_lshr_subvector_uitofp:
663 ; X32-NEXT: vpsrld $2, %xmm0, %xmm1
664 ; X32-NEXT: vpsrld $1, %xmm0, %xmm0
665 ; X32-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
666 ; X32-NEXT: vcvtdq2pd %xmm0, %xmm0
669 ; X64-LABEL: knownbits_lshr_subvector_uitofp:
671 ; X64-NEXT: vpsrld $2, %xmm0, %xmm1
672 ; X64-NEXT: vpsrld $1, %xmm0, %xmm0
673 ; X64-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7]
674 ; X64-NEXT: vcvtdq2pd %xmm0, %xmm0
676 %1 = lshr <4 x i32> %x, <i32 1, i32 2, i32 0, i32 0>
677 %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <2 x i32> <i32 0, i32 1>
678 %3 = uitofp <2 x i32> %2 to <2 x double>