@@ -74,13 +74,17 @@ pub(crate) fn detect_features() -> cache::Initializer {
74
74
extended_features_ecx,
75
75
extended_features_edx,
76
76
extended_features_eax_leaf_1,
77
+ extended_features_edx_leaf_1,
77
78
) = if max_basic_leaf >= 7 {
78
79
let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid ( 0x0000_0007_u32 ) } ;
79
- let CpuidResult { eax : eax_1, .. } =
80
- unsafe { __cpuid_count ( 0x0000_0007_u32 , 0x0000_0001_u32 ) } ;
81
- ( ebx, ecx, edx, eax_1)
80
+ let CpuidResult {
81
+ eax : eax_1,
82
+ edx : edx_1,
83
+ ..
84
+ } = unsafe { __cpuid_count ( 0x0000_0007_u32 , 0x0000_0001_u32 ) } ;
85
+ ( ebx, ecx, edx, eax_1, edx_1)
82
86
} else {
83
- ( 0 , 0 , 0 , 0 ) // CPUID does not support "Extended Features"
87
+ ( 0 , 0 , 0 , 0 , 0 ) // CPUID does not support "Extended Features"
84
88
} ;
85
89
86
90
// EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported
@@ -129,6 +133,10 @@ pub(crate) fn detect_features() -> cache::Initializer {
129
133
enable ( proc_info_edx, 26 , Feature :: sse2) ;
130
134
enable ( extended_features_ebx, 29 , Feature :: sha) ;
131
135
136
+ enable ( extended_features_ecx, 8 , Feature :: gfni) ;
137
+ enable ( extended_features_ecx, 9 , Feature :: vaes) ;
138
+ enable ( extended_features_ecx, 10 , Feature :: vpclmulqdq) ;
139
+
132
140
enable ( extended_features_ebx, 3 , Feature :: bmi1) ;
133
141
enable ( extended_features_ebx, 8 , Feature :: bmi2) ;
134
142
@@ -165,8 +173,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
165
173
let xcr0 = unsafe { _xgetbv ( 0 ) } ;
166
174
// Test `XCR0.SSE[1]` and `XCR0.AVX[2]` with the mask `0b110 == 6`:
167
175
let os_avx_support = xcr0 & 6 == 6 ;
168
- // Test `XCR0.AVX-512[7:5]` with the mask `0b1110_0000 == 224 `:
169
- let os_avx512_support = xcr0 & 224 == 224 ;
176
+ // Test `XCR0.AVX-512[7:5]` with the mask `0b1110_0000 == 0xe0 `:
177
+ let os_avx512_support = xcr0 & 0xe0 == 0xe0 ;
170
178
171
179
// Only if the OS and the CPU support saving/restoring the AVX
172
180
// registers we enable `xsave` support:
@@ -203,6 +211,13 @@ pub(crate) fn detect_features() -> cache::Initializer {
203
211
enable ( proc_info_ecx, 28 , Feature :: avx) ;
204
212
enable ( extended_features_ebx, 5 , Feature :: avx2) ;
205
213
214
+ // "Short" versions of AVX512 instructions
215
+ enable ( extended_features_eax_leaf_1, 4 , Feature :: avxvnni) ;
216
+ enable ( extended_features_eax_leaf_1, 23 , Feature :: avxifma) ;
217
+ enable ( extended_features_edx_leaf_1, 4 , Feature :: avxvnniint8) ;
218
+ enable ( extended_features_edx_leaf_1, 5 , Feature :: avxneconvert) ;
219
+ enable ( extended_features_edx_leaf_1, 10 , Feature :: avxvnniint16) ;
220
+
206
221
// For AVX-512 the OS also needs to support saving/restoring
207
222
// the extended state, only then we enable AVX-512 support:
208
223
if os_avx512_support {
@@ -216,9 +231,6 @@ pub(crate) fn detect_features() -> cache::Initializer {
216
231
enable ( extended_features_ebx, 31 , Feature :: avx512vl) ;
217
232
enable ( extended_features_ecx, 1 , Feature :: avx512vbmi) ;
218
233
enable ( extended_features_ecx, 6 , Feature :: avx512vbmi2) ;
219
- enable ( extended_features_ecx, 8 , Feature :: gfni) ;
220
- enable ( extended_features_ecx, 9 , Feature :: vaes) ;
221
- enable ( extended_features_ecx, 10 , Feature :: vpclmulqdq) ;
222
234
enable ( extended_features_ecx, 11 , Feature :: avx512vnni) ;
223
235
enable ( extended_features_ecx, 12 , Feature :: avx512bitalg) ;
224
236
enable ( extended_features_ecx, 14 , Feature :: avx512vpopcntdq) ;
0 commit comments