Skip to content

Commit d19a279

Browse files
authored
macOS lazily saves the AVX512 context (#36330)
1 parent 6385107 commit d19a279

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/processor_x86.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,14 @@ static NOINLINE std::pair<uint32_t,FeatureList<feature_sz>> _get_host_cpu(void)
545545
unset_bits(features, 32 + 27);
546546
if (!hasavx)
547547
features_disable_avx(features);
548+
#ifdef _OS_DARWIN_
549+
// See https://github.com/llvm/llvm-project/commit/82921bf2baed96b700f90b090d5dc2530223d9c0
550+
// and https://github.com/apple/darwin-xnu/blob/a449c6a3b8014d9406c2ddbdc81795da24aa7443/osfmk/i386/fpu.c#L174
551+
// Darwin lazily saves the AVX512 context on first use
552+
bool hasavx512save = hasavx;
553+
#else
548554
bool hasavx512save = hasavx && test_all_bits(xcr0, 0xe0);
555+
#endif
549556
if (!hasavx512save)
550557
features_disable_avx512(features);
551558
// Ignore feature bits that we are not interested in.

0 commit comments

Comments
 (0)