From 239ad907b1fc08874042f8bea5f61eaf3ba2877d Mon Sep 17 00:00:00 2001 From: liuhongt Date: Wed, 3 Jul 2024 14:47:33 +0800 Subject: Move runtime check into a separate function and guard it with target ("no-avx") The patch can avoid SIGILL on non-AVX512 machine due to kmovd is generated in dynamic check. gcc/testsuite/ChangeLog: PR target/115748 * gcc.target/i386/avx512-check.h: Move runtime check into a separate function and guard it with target ("no-avx"). --- gcc/testsuite/gcc.target/i386/avx512-check.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/testsuite/gcc.target/i386/avx512-check.h b/gcc/testsuite/gcc.target/i386/avx512-check.h index 0ad9064..71858a3 100644 --- a/gcc/testsuite/gcc.target/i386/avx512-check.h +++ b/gcc/testsuite/gcc.target/i386/avx512-check.h @@ -34,8 +34,9 @@ check_osxsave (void) return (ecx & bit_OSXSAVE) != 0; } +__attribute__((noipa,target("no-avx"))) int -main () +avx512_runtime_support_p () { unsigned int eax, ebx, ecx, edx; @@ -101,6 +102,17 @@ main () #endif && avx512f_os_support ()) { + return 1; + } + + return 0; +} + +int +main () +{ + if (avx512_runtime_support_p ()) + { DO_TEST (); #ifdef DEBUG printf ("PASSED\n"); -- cgit v1.1