@@ -74,13 +74,17 @@ pub(crate) fn detect_features() -> cache::Initializer {
7474 extended_features_ecx,
7575 extended_features_edx,
7676 extended_features_eax_leaf_1,
77+ extended_features_edx_leaf_1,
7778 ) = if max_basic_leaf >= 7 {
7879 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)
8286 } else {
83- ( 0 , 0 , 0 , 0 ) // CPUID does not support "Extended Features"
87+ ( 0 , 0 , 0 , 0 , 0 ) // CPUID does not support "Extended Features"
8488 } ;
8589
8690 // EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported
@@ -129,6 +133,10 @@ pub(crate) fn detect_features() -> cache::Initializer {
129133 enable ( proc_info_edx, 26 , Feature :: sse2) ;
130134 enable ( extended_features_ebx, 29 , Feature :: sha) ;
131135
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+
132140 enable ( extended_features_ebx, 3 , Feature :: bmi1) ;
133141 enable ( extended_features_ebx, 8 , Feature :: bmi2) ;
134142
@@ -165,8 +173,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
165173 let xcr0 = unsafe { _xgetbv ( 0 ) } ;
166174 // Test `XCR0.SSE[1]` and `XCR0.AVX[2]` with the mask `0b110 == 6`:
167175 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 ;
170178
171179 // Only if the OS and the CPU support saving/restoring the AVX
172180 // registers we enable `xsave` support:
@@ -203,6 +211,13 @@ pub(crate) fn detect_features() -> cache::Initializer {
203211 enable ( proc_info_ecx, 28 , Feature :: avx) ;
204212 enable ( extended_features_ebx, 5 , Feature :: avx2) ;
205213
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+
206221 // For AVX-512 the OS also needs to support saving/restoring
207222 // the extended state, only then we enable AVX-512 support:
208223 if os_avx512_support {
@@ -216,9 +231,6 @@ pub(crate) fn detect_features() -> cache::Initializer {
216231 enable ( extended_features_ebx, 31 , Feature :: avx512vl) ;
217232 enable ( extended_features_ecx, 1 , Feature :: avx512vbmi) ;
218233 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) ;
222234 enable ( extended_features_ecx, 11 , Feature :: avx512vnni) ;
223235 enable ( extended_features_ecx, 12 , Feature :: avx512bitalg) ;
224236 enable ( extended_features_ecx, 14 , Feature :: avx512vpopcntdq) ;
0 commit comments