diff options
| author | Mingzhuo Yin <yinmingzhuo@gmail.com> | 2024-03-03 00:53:35 +0800 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2024-03-05 23:16:09 +0000 |
| commit | 210913f1c4d46e33f5a18a7105b15371ca24ece0 (patch) | |
| tree | 94e72512910e32900fe38e42a728bcbed28a7ece /library/stdarch/crates/std_detect | |
| parent | f32ad010a65b86aa131e51f104c2103244b034c1 (diff) | |
| download | rust-210913f1c4d46e33f5a18a7105b15371ca24ece0.tar.gz rust-210913f1c4d46e33f5a18a7105b15371ca24ece0.zip | |
fix: invalid bit for detecting avx512 feature
Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com>
Diffstat (limited to 'library/stdarch/crates/std_detect')
| -rw-r--r-- | library/stdarch/crates/std_detect/src/detect/os/x86.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/library/stdarch/crates/std_detect/src/detect/os/x86.rs b/library/stdarch/crates/std_detect/src/detect/os/x86.rs index 4ff9ac5f13b..971e56c1403 100644 --- a/library/stdarch/crates/std_detect/src/detect/os/x86.rs +++ b/library/stdarch/crates/std_detect/src/detect/os/x86.rs @@ -69,13 +69,19 @@ pub(crate) fn detect_features() -> cache::Initializer { // EAX = 7, ECX = 0: Queries "Extended Features"; // Contains information about bmi,bmi2, and avx2 support. - let (extended_features_ebx, extended_features_ecx, extended_features_edx) = - if max_basic_leaf >= 7 { - let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid(0x0000_0007_u32) }; - (ebx, ecx, edx) - } else { - (0, 0, 0) // CPUID does not support "Extended Features" - }; + let ( + extended_features_eax, + extended_features_ebx, + extended_features_ecx, + extended_features_edx, + ) = if max_basic_leaf >= 7 { + let CpuidResult { + eax, ebx, ecx, edx, .. + } = unsafe { __cpuid(0x0000_0007_u32) }; + (eax, ebx, ecx, edx) + } else { + (0, 0, 0, 0) // CPUID does not support "Extended Features" + }; // EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported // - EAX returns the max leaf value for extended information, that is, @@ -200,6 +206,7 @@ pub(crate) fn detect_features() -> cache::Initializer { // For AVX-512 the OS also needs to support saving/restoring // the extended state, only then we enable AVX-512 support: if os_avx512_support { + enable(extended_features_eax, 5, Feature::avx512bf16); enable(extended_features_ebx, 16, Feature::avx512f); enable(extended_features_ebx, 17, Feature::avx512dq); enable(extended_features_ebx, 21, Feature::avx512ifma); @@ -209,15 +216,14 @@ pub(crate) fn detect_features() -> cache::Initializer { enable(extended_features_ebx, 30, Feature::avx512bw); enable(extended_features_ebx, 31, Feature::avx512vl); enable(extended_features_ecx, 1, Feature::avx512vbmi); - enable(extended_features_ecx, 5, Feature::avx512bf16); enable(extended_features_ecx, 6, Feature::avx512vbmi2); enable(extended_features_ecx, 8, Feature::gfni); - enable(extended_features_ecx, 8, Feature::avx512vp2intersect); enable(extended_features_ecx, 9, Feature::vaes); enable(extended_features_ecx, 10, Feature::vpclmulqdq); enable(extended_features_ecx, 11, Feature::avx512vnni); enable(extended_features_ecx, 12, Feature::avx512bitalg); enable(extended_features_ecx, 14, Feature::avx512vpopcntdq); + enable(extended_features_edx, 8, Feature::avx512vp2intersect); enable(extended_features_edx, 23, Feature::avx512fp16); } } |
