Skip to content

Commit 46affa2

Browse files
committed
Require fma and f16c for avx512f in std_detect
1 parent 1245618 commit 46affa2

File tree

1 file changed

+8
-1
lines changed
  • crates/std_detect/src/detect/os

1 file changed

+8
-1
lines changed

crates/std_detect/src/detect/os/x86.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,16 @@ pub(crate) fn detect_features() -> cache::Initializer {
233233
enable(extended_features_eax_leaf_1, 1, Feature::sm3);
234234
enable(extended_features_eax_leaf_1, 2, Feature::sm4);
235235

236+
let f16c = bit::test(proc_info_ecx as usize, 29);
237+
let fma = bit::test(proc_info_ecx as usize, 12);
238+
236239
// For AVX-512 the OS also needs to support saving/restoring
237240
// the extended state, only then we enable AVX-512 support:
238-
if os_avx512_support {
241+
// Also, Rust makes `avx512f` imply `fma` and `f16c`, because
242+
// otherwise the assembler is broken. But Intel doesn't guarantee
243+
// that `fma` and `f16c` are available with `avx512f`, so we
244+
// need to check for them separately.
245+
if os_avx512_support && f16c && fma {
239246
enable(extended_features_ebx, 16, Feature::avx512f);
240247
enable(extended_features_ebx, 17, Feature::avx512dq);
241248
enable(extended_features_ebx, 21, Feature::avx512ifma);

0 commit comments

Comments
 (0)