1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX1
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX2
5 declare i32 @llvm.x86.avx.movmsk.pd.256(<4 x double>)
6 declare i32 @llvm.x86.avx.movmsk.ps.256(<8 x float>)
8 ; Use widest possible vector for movmsk comparisons (PR37087)
10 define i1 @movmskps_noneof_bitcast_v4f64(<4 x double> %a0) {
11 ; CHECK-LABEL: movmskps_noneof_bitcast_v4f64:
13 ; CHECK-NEXT: vxorpd %xmm1, %xmm1, %xmm1
14 ; CHECK-NEXT: vcmpeqpd %ymm1, %ymm0, %ymm0
15 ; CHECK-NEXT: vmovmskpd %ymm0, %eax
16 ; CHECK-NEXT: testl %eax, %eax
17 ; CHECK-NEXT: sete %al
18 ; CHECK-NEXT: vzeroupper
20 %1 = fcmp oeq <4 x double> %a0, zeroinitializer
21 %2 = sext <4 x i1> %1 to <4 x i64>
22 %3 = bitcast <4 x i64> %2 to <8 x float>
23 %4 = tail call i32 @llvm.x86.avx.movmsk.ps.256(<8 x float> %3)
24 %5 = icmp eq i32 %4, 0
28 define i1 @movmskps_allof_bitcast_v4f64(<4 x double> %a0) {
29 ; CHECK-LABEL: movmskps_allof_bitcast_v4f64:
31 ; CHECK-NEXT: vxorpd %xmm1, %xmm1, %xmm1
32 ; CHECK-NEXT: vcmpeqpd %ymm1, %ymm0, %ymm0
33 ; CHECK-NEXT: vmovmskpd %ymm0, %eax
34 ; CHECK-NEXT: cmpl $15, %eax
35 ; CHECK-NEXT: sete %al
36 ; CHECK-NEXT: vzeroupper
38 %1 = fcmp oeq <4 x double> %a0, zeroinitializer
39 %2 = sext <4 x i1> %1 to <4 x i64>
40 %3 = bitcast <4 x i64> %2 to <8 x float>
41 %4 = tail call i32 @llvm.x86.avx.movmsk.ps.256(<8 x float> %3)
42 %5 = icmp eq i32 %4, 255
47 ; TODO - Avoid sign extension ops when just extracting the sign bits.
50 define i32 @movmskpd_cmpgt_v4i64(<4 x i64> %a0) {
51 ; AVX1-LABEL: movmskpd_cmpgt_v4i64:
53 ; AVX1-NEXT: vpxor %xmm1, %xmm1, %xmm1
54 ; AVX1-NEXT: vpcmpgtq %xmm0, %xmm1, %xmm1
55 ; AVX1-NEXT: vblendpd {{.*#+}} ymm0 = ymm1[0,1],ymm0[2,3]
56 ; AVX1-NEXT: vmovmskpd %ymm0, %eax
57 ; AVX1-NEXT: vzeroupper
60 ; AVX2-LABEL: movmskpd_cmpgt_v4i64:
62 ; AVX2-NEXT: vmovmskpd %ymm0, %eax
63 ; AVX2-NEXT: vzeroupper
65 %1 = icmp sgt <4 x i64> zeroinitializer, %a0
66 %2 = sext <4 x i1> %1 to <4 x i64>
67 %3 = bitcast <4 x i64> %2 to <4 x double>
68 %4 = tail call i32 @llvm.x86.avx.movmsk.pd.256(<4 x double> %3)
72 define i32 @movmskps_ashr_v8i32(<8 x i32> %a0) {
73 ; AVX1-LABEL: movmskps_ashr_v8i32:
75 ; AVX1-NEXT: vpsrad $31, %xmm0, %xmm1
76 ; AVX1-NEXT: vblendps {{.*#+}} ymm0 = ymm1[0,1,2,3],ymm0[4,5,6,7]
77 ; AVX1-NEXT: vmovmskps %ymm0, %eax
78 ; AVX1-NEXT: vzeroupper
81 ; AVX2-LABEL: movmskps_ashr_v8i32:
83 ; AVX2-NEXT: vmovmskps %ymm0, %eax
84 ; AVX2-NEXT: vzeroupper
86 %1 = ashr <8 x i32> %a0, <i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31>
87 %2 = bitcast <8 x i32> %1 to <8 x float>
88 %3 = tail call i32 @llvm.x86.avx.movmsk.ps.256(<8 x float> %2)
92 define i32 @movmskps_sext_v4i64(<4 x i32> %a0) {
93 ; AVX1-LABEL: movmskps_sext_v4i64:
95 ; AVX1-NEXT: vpmovsxdq %xmm0, %xmm1
96 ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
97 ; AVX1-NEXT: vpmovsxdq %xmm0, %xmm0
98 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm1, %ymm0
99 ; AVX1-NEXT: vmovmskpd %ymm0, %eax
100 ; AVX1-NEXT: vzeroupper
103 ; AVX2-LABEL: movmskps_sext_v4i64:
105 ; AVX2-NEXT: vpmovsxdq %xmm0, %ymm0
106 ; AVX2-NEXT: vmovmskpd %ymm0, %eax
107 ; AVX2-NEXT: vzeroupper
109 %1 = sext <4 x i32> %a0 to <4 x i64>
110 %2 = bitcast <4 x i64> %1 to <4 x double>
111 %3 = tail call i32 @llvm.x86.avx.movmsk.pd.256(<4 x double> %2)
115 define i32 @movmskps_sext_v8i32(<8 x i16> %a0) {
116 ; AVX1-LABEL: movmskps_sext_v8i32:
118 ; AVX1-NEXT: vpmovsxwd %xmm0, %xmm1
119 ; AVX1-NEXT: vpshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
120 ; AVX1-NEXT: vpmovsxwd %xmm0, %xmm0
121 ; AVX1-NEXT: vinsertf128 $1, %xmm0, %ymm1, %ymm0
122 ; AVX1-NEXT: vmovmskps %ymm0, %eax
123 ; AVX1-NEXT: vzeroupper
126 ; AVX2-LABEL: movmskps_sext_v8i32:
128 ; AVX2-NEXT: vpmovsxwd %xmm0, %ymm0
129 ; AVX2-NEXT: vmovmskps %ymm0, %eax
130 ; AVX2-NEXT: vzeroupper
132 %1 = sext <8 x i16> %a0 to <8 x i32>
133 %2 = bitcast <8 x i32> %1 to <8 x float>
134 %3 = tail call i32 @llvm.x86.avx.movmsk.ps.256(<8 x float> %2)