From: Uros Bizjak Date: Sun, 3 Sep 2017 23:17:26 +0000 (+0200) Subject: adx-check.h (main): Use __get_cpuid_count. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83982f26ba60079004a96f1b69aebb8d2bf7bb38;p=gcc.git adx-check.h (main): Use __get_cpuid_count. * gcc.target/i386/adx-check.h (main): Use __get_cpuid_count. * gcc.target/i386/bmi-check.h (main): Ditto. * gcc.target/i386/bmi2-check.h (main): Ditto. * gcc.target/i386/rtm-check.h (main): Ditto. * gcc.target/i386/sha-check.h (main): Ditto. * gcc.target/i386/avx2-check.h (check_osxsave): New function. (main): Use __get_cpuid_count. Use check_osxsave. * gcc.target/i386/avx512-check.h (check_osxsave): New function. (main): Use __get_cpuid_count. Use check_osxsave. Reorder conditions. * gcc.target/i386/mpx/mpx-check.h (check_osxsave): New function. (main): Use check_osxsave. From-SVN: r251629 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 18e7739b4a7..628c1f3efd6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2017-09-04 Uros Bizjak + + * gcc.target/i386/adx-check.h (main): Use __get_cpuid_count. + * gcc.target/i386/bmi-check.h (main): Ditto. + * gcc.target/i386/bmi2-check.h (main): Ditto. + * gcc.target/i386/rtm-check.h (main): Ditto. + * gcc.target/i386/sha-check.h (main): Ditto. + * gcc.target/i386/avx2-check.h (check_osxsave): New function. + (main): Use __get_cpuid_count. Use check_osxsave. + * gcc.target/i386/avx512-check.h (check_osxsave): New function. + (main): Use __get_cpuid_count. Use check_osxsave. Reorder conditions. + * gcc.target/i386/mpx/mpx-check.h (check_osxsave): New function. + (main): Use check_osxsave. + 2017-09-03 Uros Bizjak * gcc.target/i386/mpx/mpx-check.h (main): Use __get_cpuid_count diff --git a/gcc/testsuite/gcc.target/i386/adx-check.h b/gcc/testsuite/gcc.target/i386/adx-check.h index 5e7ad965251..cfed1a38483 100644 --- a/gcc/testsuite/gcc.target/i386/adx-check.h +++ b/gcc/testsuite/gcc.target/i386/adx-check.h @@ -8,21 +8,15 @@ static void __attribute__ ((noinline)) do_test (void) adx_test (); } - int +int main () { unsigned int eax, ebx, ecx, edx; - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) return 0; /* Run ADX test only if host has ADX support. */ - - if (__get_cpuid_max (0, NULL) < 7) - return 0; - - __cpuid_count (7, 0, eax, ebx, ecx, edx); - if (ebx & bit_ADX) { do_test (); @@ -31,10 +25,10 @@ main () #endif return 0; } + #ifdef DEBUG printf ("SKIPPED\n"); #endif - return 0; } diff --git a/gcc/testsuite/gcc.target/i386/avx2-check.h b/gcc/testsuite/gcc.target/i386/avx2-check.h index 021e1e6b8e8..25bed5e0da6 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-check.h +++ b/gcc/testsuite/gcc.target/i386/avx2-check.h @@ -10,38 +10,35 @@ static void __attribute__ ((noinline)) do_test (void) avx2_test (); } +static int +check_osxsave (void) +{ + unsigned int eax, ebx, ecx, edx; + + __cpuid (1, eax, ebx, ecx, edx); + return (ecx & bit_OSXSAVE) != 0; +} + int main () { unsigned int eax, ebx, ecx, edx; - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) return 0; /* Run AVX2 test only if host has AVX2 support. */ - if (ecx & bit_OSXSAVE) + if (check_osxsave () && (ebx & bit_AVX2) && avx_os_support ()) { - if (__get_cpuid_max (0, NULL) < 7) - return 0; - - __cpuid_count (7, 0, eax, ebx, ecx, edx); - - if ((ebx & bit_AVX2) && avx_os_support ()) - { - do_test (); -#ifdef DEBUG - printf ("PASSED\n"); -#endif - return 0; - } + do_test (); #ifdef DEBUG - printf ("SKIPPED\n"); + printf ("PASSED\n"); #endif + return 0; } + #ifdef DEBUG - else - printf ("SKIPPED\n"); + printf ("SKIPPED\n"); #endif - return 0; } diff --git a/gcc/testsuite/gcc.target/i386/avx512-check.h b/gcc/testsuite/gcc.target/i386/avx512-check.h index bfe14960100..9693fa46721 100644 --- a/gcc/testsuite/gcc.target/i386/avx512-check.h +++ b/gcc/testsuite/gcc.target/i386/avx512-check.h @@ -25,87 +25,65 @@ do_test (void) } #endif -int -main () +static int +check_osxsave (void) { unsigned int eax, ebx, ecx, edx; - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) - goto skipped; - - /* Run AVX512F test only if host has AVX512F support. */ - if (!(ecx & bit_OSXSAVE)) - goto skipped; - - if (__get_cpuid_max (0, NULL) < 7) - goto skipped; + __cpuid (1, eax, ebx, ecx, edx); + return (ecx & bit_OSXSAVE) != 0; +} - __cpuid_count (7, 0, eax, ebx, ecx, edx); +int +main () +{ + unsigned int eax, ebx, ecx, edx; - if (!(ebx & bit_AVX512F)) - goto skipped; + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) + return 0; + /* Run AVX512 test only if host has ISA support. */ + if (check_osxsave () + && (ebx & bit_AVX512F) #ifdef AVX512VL - if (!(ebx & bit_AVX512VL)) - goto skipped; + && (ebx & bit_AVX512VL) #endif - #ifdef AVX512ER - if (!(ebx & bit_AVX512ER)) - goto skipped; + && (ebx & bit_AVX512ER) #endif - #ifdef AVX512CD - if (!(ebx & bit_AVX512CD)) - goto skipped; + && (ebx & bit_AVX512CD) #endif - #ifdef AVX512DQ - if (!(ebx & bit_AVX512DQ)) - goto skipped; + && (ebx & bit_AVX512DQ) #endif - #ifdef AVX512BW - if (!(ebx & bit_AVX512BW)) - goto skipped; + && (ebx & bit_AVX512BW) #endif - #ifdef AVX512IFMA - if (!(ebx & bit_AVX512IFMA)) - goto skipped; + && (ebx & bit_AVX512IFMA) #endif - #ifdef AVX512VBMI - if (!(ecx & bit_AVX512VBMI)) - goto skipped; + && (ecx & bit_AVX512VBMI) #endif - #ifdef AVX5124FMAPS - if (!(edx & bit_AVX5124FMAPS)) - goto skipped; + && (edx & bit_AVX5124FMAPS) #endif - #ifdef AVX5124VNNIW - if (!(edx & bit_AVX5124VNNIW)) - goto skipped; + && (edx & bit_AVX5124VNNIW) #endif - #ifdef AVX512VPOPCNTDQ - if (!(ecx & bit_AVX512VPOPCNTDQ)) - goto skipped; + && (ecx & bit_AVX512VPOPCNTDQ) #endif - - if (!avx512f_os_support ()) - goto skipped; - - DO_TEST (); - + && avx512f_os_support ()) + { + DO_TEST (); #ifdef DEBUG - printf ("PASSED\n"); + printf ("PASSED\n"); #endif - return 0; - -skipped: + return 0; + } + #ifdef DEBUG printf ("SKIPPED\n"); #endif diff --git a/gcc/testsuite/gcc.target/i386/bmi-check.h b/gcc/testsuite/gcc.target/i386/bmi-check.h index 8fad38ad072..1973f3b6468 100644 --- a/gcc/testsuite/gcc.target/i386/bmi-check.h +++ b/gcc/testsuite/gcc.target/i386/bmi-check.h @@ -17,23 +17,21 @@ main () { unsigned int eax, ebx, ecx, edx; - if (__get_cpuid_max (0, NULL) < 7) + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) return 0; - __cpuid_count (7, 0, eax, ebx, ecx, edx); - /* Run BMI test only if host has BMI support. */ if (ebx & bit_BMI) { do_test (); #ifdef DEBUG - printf ("PASSED\n"); + printf ("PASSED\n"); #endif + return 0; } + #ifdef DEBUG - else - printf ("SKIPPED\n"); + printf ("SKIPPED\n"); #endif - return 0; } diff --git a/gcc/testsuite/gcc.target/i386/bmi2-check.h b/gcc/testsuite/gcc.target/i386/bmi2-check.h index c933a49f281..ba91ef9b780 100644 --- a/gcc/testsuite/gcc.target/i386/bmi2-check.h +++ b/gcc/testsuite/gcc.target/i386/bmi2-check.h @@ -1,6 +1,5 @@ #include #include - #include "cpuid.h" static void bmi2_test (void); @@ -17,11 +16,9 @@ main () { unsigned int eax, ebx, ecx, edx; - if (__get_cpuid_max (0, NULL) < 7) + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) return 0; - __cpuid_count (7, 0, eax, ebx, ecx, edx); - /* Run BMI2 test only if host has BMI2 support. */ if (ebx & bit_BMI2) { @@ -29,11 +26,11 @@ main () #ifdef DEBUG printf ("PASSED\n"); #endif + return 0; } + #ifdef DEBUG - else - printf ("SKIPPED\n"); + printf ("SKIPPED\n"); #endif - return 0; } diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h index dd90fbd275a..d84b8bf0efa 100644 --- a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h +++ b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h @@ -26,6 +26,15 @@ static int xgetbv (unsigned x) return eax; } +static int +check_osxsave (void) +{ + unsigned int eax, ebx, ecx, edx; + + __cpuid (1, eax, ebx, ecx, edx); + return (ecx & bit_OSXSAVE) != 0; +} + int main (int argc, const char **argv) { @@ -35,7 +44,7 @@ main (int argc, const char **argv) return NORUNRES; /* Run MPX test only if host has MPX support. */ - if ((ebx & bit_MPX) && (xgetbv (0) & XSTATE_BNDREGS)) + if (check_osxsave () && (ebx & bit_MPX) && (xgetbv (0) & XSTATE_BNDREGS)) mpx_test (argc, argv); else { diff --git a/gcc/testsuite/gcc.target/i386/rtm-check.h b/gcc/testsuite/gcc.target/i386/rtm-check.h index 593b40391c7..bdb5a6dc0bf 100644 --- a/gcc/testsuite/gcc.target/i386/rtm-check.h +++ b/gcc/testsuite/gcc.target/i386/rtm-check.h @@ -13,18 +13,19 @@ main () { unsigned int eax, ebx, ecx, edx; - if (__get_cpuid_max (0, NULL) >= 7) + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) + return 0; + + /* Run RTM test only if host has RTM support. */ + if (ebx & bit_RTM) { - __cpuid_count (7, 0, eax, ebx, ecx, edx); - if (ebx & bit_RTM) - { - do_test (); + do_test (); #ifdef DEBUG - printf ("PASSED\n"); + printf ("PASSED\n"); #endif - return 0; - } + return 0; } + #ifdef DEBUG printf ("SKIPPED\n"); #endif diff --git a/gcc/testsuite/gcc.target/i386/sha-check.h b/gcc/testsuite/gcc.target/i386/sha-check.h index e0a18076e15..5bc5a59ab80 100644 --- a/gcc/testsuite/gcc.target/i386/sha-check.h +++ b/gcc/testsuite/gcc.target/i386/sha-check.h @@ -15,19 +15,17 @@ main () { unsigned int eax, ebx, ecx, edx; - if (__get_cpuid_max (0, NULL) >= 7) - { - __cpuid_count (7, 0, eax, ebx, ecx, edx); + if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) + return 0; - /* Run SHA test only if host has SHA support. */ - if (ebx & bit_SHA) - { - do_test (); + /* Run SHA test only if host has SHA support. */ + if (ebx & bit_SHA) + { + do_test (); #ifdef DEBUG - printf ("PASSED\n"); + printf ("PASSED\n"); #endif - return 0; - } + return 0; } #ifdef DEBUG