Tested on x86_64-linux/darwin, pushed to trunk, thanks,
Iain
--- 8< ---
Darwin enables the avx512 XSAVE state lazily; reading XCR0 is not
reliable - query the kernel instead.
gcc/testsuite/ChangeLog:
* lib/target-supports.exp (check_avx512_os_support_available):
Query the kernel for avx512 availability on Darwin.
Signed-off-by: Iain Sandoe <[email protected]>
---
gcc/testsuite/lib/target-supports.exp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index cbd39301a8b..5eb44cb3ee4 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2896,6 +2896,20 @@ proc check_avx512_os_support_available { } {
} else {
# Check that OS has AVX512, AVX and SSE saving enabled.
check_runtime_nocache avx512_os_support_available {
+ #ifdef __APPLE__
+ #include <sys/sysctl.h>
+ int main ()
+ {
+ int val = 0;
+ size_t len = sizeof (val);
+ /* Darwin enables the avx512 XSAVE state lazily; reading XCR0
+ is not reliable - query the kernel instead. */
+ if (sysctlbyname ("hw.optional.avx512f", &val, &len, 0, 0)
+ != 0 || val == 0)
+ return 1;
+ return 0;
+ }
+ #else
int main ()
{
unsigned int eax, edx;
@@ -2903,6 +2917,7 @@ proc check_avx512_os_support_available { } {
asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
return (eax & 0xe6) != 0xe6;
}
+ #endif
} ""
}
}]
--
2.50.1 (Apple Git-155)