avx512-movmsk.ll
6.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=avx512vl | FileCheck %s --check-prefixes=AVX512VL
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mattr=avx512vl,avx512dq,avx512bw | FileCheck %s --check-prefixes=AVX512VLDQBW
; This test makes sure we don't use movmsk instructions when masked compares
; would be better. The use of the getmant intrinsic introduces a convertion
; scalar to vXi1 late after movmsk has been formed. Requiring it to be reversed.
declare <2 x double> @llvm.x86.avx512.mask.getmant.pd.128(<2 x double>, i32, <2 x double>, i8)
declare <4 x double> @llvm.x86.avx512.mask.getmant.pd.256(<4 x double>, i32, <4 x double>, i8)
declare <8 x double> @llvm.x86.avx512.mask.getmant.pd.512(<8 x double>, i32, <8 x double>, i8, i32)
declare <16 x float> @llvm.x86.avx512.mask.getmant.ps.512(<16 x float>, i32, <16 x float>, i16, i32)
define <2 x double> @movmsk2(<2 x double> %x0, <2 x double> %x2, <2 x i64> %mask) {
; AVX512VL-LABEL: movmsk2:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpxor %xmm3, %xmm3, %xmm3
; AVX512VL-NEXT: vpcmpgtq %xmm2, %xmm3, %k1
; AVX512VL-NEXT: vgetmantpd $11, %xmm0, %xmm1 {%k1}
; AVX512VL-NEXT: vmovapd %xmm1, %xmm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk2:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovq2m %xmm2, %k1
; AVX512VLDQBW-NEXT: vgetmantpd $11, %xmm0, %xmm1 {%k1}
; AVX512VLDQBW-NEXT: vmovapd %xmm1, %xmm0
; AVX512VLDQBW-NEXT: retq
%a = icmp slt <2 x i64> %mask, zeroinitializer
%b = bitcast <2 x i1> %a to i2
%c = zext i2 %b to i8
%res = call <2 x double> @llvm.x86.avx512.mask.getmant.pd.128(<2 x double> %x0, i32 11, <2 x double> %x2, i8 %c)
ret <2 x double> %res
}
define <4 x double> @movmsk4(<4 x double> %x0, <4 x double> %x2, <4 x i32> %mask) {
; AVX512VL-LABEL: movmsk4:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpxor %xmm3, %xmm3, %xmm3
; AVX512VL-NEXT: vpcmpgtd %xmm2, %xmm3, %k1
; AVX512VL-NEXT: vgetmantpd $11, %ymm0, %ymm1 {%k1}
; AVX512VL-NEXT: vmovapd %ymm1, %ymm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk4:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovd2m %xmm2, %k1
; AVX512VLDQBW-NEXT: vgetmantpd $11, %ymm0, %ymm1 {%k1}
; AVX512VLDQBW-NEXT: vmovapd %ymm1, %ymm0
; AVX512VLDQBW-NEXT: retq
%a = icmp slt <4 x i32> %mask, zeroinitializer
%b = bitcast <4 x i1> %a to i4
%c = zext i4 %b to i8
%res = call <4 x double> @llvm.x86.avx512.mask.getmant.pd.256(<4 x double> %x0, i32 11, <4 x double> %x2, i8 %c)
ret <4 x double> %res
}
define <8 x double> @movmsk8(<8 x double> %x0, <8 x double> %x2, <8 x i32> %mask) {
; AVX512VL-LABEL: movmsk8:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpxor %xmm3, %xmm3, %xmm3
; AVX512VL-NEXT: vpcmpgtd %ymm2, %ymm3, %k1
; AVX512VL-NEXT: vgetmantpd $11, %zmm0, %zmm1 {%k1}
; AVX512VL-NEXT: vmovapd %zmm1, %zmm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk8:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovd2m %ymm2, %k1
; AVX512VLDQBW-NEXT: vgetmantpd $11, %zmm0, %zmm1 {%k1}
; AVX512VLDQBW-NEXT: vmovapd %zmm1, %zmm0
; AVX512VLDQBW-NEXT: retq
%a = icmp slt <8 x i32> %mask, zeroinitializer
%b = bitcast <8 x i1> %a to i8
%res = call <8 x double> @llvm.x86.avx512.mask.getmant.pd.512(<8 x double> %x0, i32 11, <8 x double> %x2, i8 %b, i32 4)
ret <8 x double> %res
}
define <16 x float> @movmsk16(<16 x float> %x0, <16 x float> %x2, <16 x i8> %mask) {
; AVX512VL-LABEL: movmsk16:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpmovmskb %xmm2, %eax
; AVX512VL-NEXT: kmovw %eax, %k1
; AVX512VL-NEXT: vgetmantps $11, %zmm0, %zmm1 {%k1}
; AVX512VL-NEXT: vmovaps %zmm1, %zmm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk16:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovb2m %xmm2, %k1
; AVX512VLDQBW-NEXT: vgetmantps $11, %zmm0, %zmm1 {%k1}
; AVX512VLDQBW-NEXT: vmovaps %zmm1, %zmm0
; AVX512VLDQBW-NEXT: retq
%a = icmp slt <16 x i8> %mask, zeroinitializer
%b = bitcast <16 x i1> %a to i16
%res = call <16 x float> @llvm.x86.avx512.mask.getmant.ps.512(<16 x float> %x0, i32 11, <16 x float> %x2, i16 %b, i32 4)
ret <16 x float> %res
}
; Similar to above but with fp types bitcasted to int for the slt.
define <2 x double> @movmsk2_fp(<2 x double> %x0, <2 x double> %x2, <2 x double> %mask) {
; AVX512VL-LABEL: movmsk2_fp:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpxor %xmm3, %xmm3, %xmm3
; AVX512VL-NEXT: vpcmpgtq %xmm2, %xmm3, %k1
; AVX512VL-NEXT: vgetmantpd $11, %xmm0, %xmm1 {%k1}
; AVX512VL-NEXT: vmovapd %xmm1, %xmm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk2_fp:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovq2m %xmm2, %k1
; AVX512VLDQBW-NEXT: vgetmantpd $11, %xmm0, %xmm1 {%k1}
; AVX512VLDQBW-NEXT: vmovapd %xmm1, %xmm0
; AVX512VLDQBW-NEXT: retq
%q = bitcast <2 x double> %mask to <2 x i64>
%a = icmp slt <2 x i64> %q, zeroinitializer
%b = bitcast <2 x i1> %a to i2
%c = zext i2 %b to i8
%res = call <2 x double> @llvm.x86.avx512.mask.getmant.pd.128(<2 x double> %x0, i32 11, <2 x double> %x2, i8 %c)
ret <2 x double> %res
}
define <4 x double> @movmsk4_fp(<4 x double> %x0, <4 x double> %x2, <4 x float> %mask) {
; AVX512VL-LABEL: movmsk4_fp:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpxor %xmm3, %xmm3, %xmm3
; AVX512VL-NEXT: vpcmpgtd %xmm2, %xmm3, %k1
; AVX512VL-NEXT: vgetmantpd $11, %ymm0, %ymm1 {%k1}
; AVX512VL-NEXT: vmovapd %ymm1, %ymm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk4_fp:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovd2m %xmm2, %k1
; AVX512VLDQBW-NEXT: vgetmantpd $11, %ymm0, %ymm1 {%k1}
; AVX512VLDQBW-NEXT: vmovapd %ymm1, %ymm0
; AVX512VLDQBW-NEXT: retq
%q = bitcast <4 x float> %mask to <4 x i32>
%a = icmp slt <4 x i32> %q, zeroinitializer
%b = bitcast <4 x i1> %a to i4
%c = zext i4 %b to i8
%res = call <4 x double> @llvm.x86.avx512.mask.getmant.pd.256(<4 x double> %x0, i32 11, <4 x double> %x2, i8 %c)
ret <4 x double> %res
}
define <8 x double> @movmsk8_fp(<8 x double> %x0, <8 x double> %x2, <8 x float> %mask) {
; AVX512VL-LABEL: movmsk8_fp:
; AVX512VL: ## %bb.0:
; AVX512VL-NEXT: vpxor %xmm3, %xmm3, %xmm3
; AVX512VL-NEXT: vpcmpgtd %ymm2, %ymm3, %k1
; AVX512VL-NEXT: vgetmantpd $11, %zmm0, %zmm1 {%k1}
; AVX512VL-NEXT: vmovapd %zmm1, %zmm0
; AVX512VL-NEXT: retq
;
; AVX512VLDQBW-LABEL: movmsk8_fp:
; AVX512VLDQBW: ## %bb.0:
; AVX512VLDQBW-NEXT: vpmovd2m %ymm2, %k1
; AVX512VLDQBW-NEXT: vgetmantpd $11, %zmm0, %zmm1 {%k1}
; AVX512VLDQBW-NEXT: vmovapd %zmm1, %zmm0
; AVX512VLDQBW-NEXT: retq
%q = bitcast <8 x float> %mask to <8 x i32>
%a = icmp slt <8 x i32> %q, zeroinitializer
%b = bitcast <8 x i1> %a to i8
%res = call <8 x double> @llvm.x86.avx512.mask.getmant.pd.512(<8 x double> %x0, i32 11, <8 x double> %x2, i8 %b, i32 4)
ret <8 x double> %res
}