Commit 83982f26 by Uros Bizjak Committed by Uros Bizjak

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
parent f36b315d
2017-09-04 Uros Bizjak <ubizjak@gmail.com>
* 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 <ubizjak@gmail.com> 2017-09-03 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/mpx/mpx-check.h (main): Use __get_cpuid_count * gcc.target/i386/mpx/mpx-check.h (main): Use __get_cpuid_count
......
...@@ -8,21 +8,15 @@ static void __attribute__ ((noinline)) do_test (void) ...@@ -8,21 +8,15 @@ static void __attribute__ ((noinline)) do_test (void)
adx_test (); adx_test ();
} }
int int
main () main ()
{ {
unsigned int eax, ebx, ecx, edx; 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; return 0;
/* Run ADX test only if host has ADX support. */ /* 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) if (ebx & bit_ADX)
{ {
do_test (); do_test ();
...@@ -31,10 +25,10 @@ main () ...@@ -31,10 +25,10 @@ main ()
#endif #endif
return 0; return 0;
} }
#ifdef DEBUG #ifdef DEBUG
printf ("SKIPPED\n"); printf ("SKIPPED\n");
#endif #endif
return 0; return 0;
} }
...@@ -10,38 +10,35 @@ static void __attribute__ ((noinline)) do_test (void) ...@@ -10,38 +10,35 @@ static void __attribute__ ((noinline)) do_test (void)
avx2_test (); 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 int
main () main ()
{ {
unsigned int eax, ebx, ecx, edx; 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; return 0;
/* Run AVX2 test only if host has AVX2 support. */ /* 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) do_test ();
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;
}
#ifdef DEBUG #ifdef DEBUG
printf ("SKIPPED\n"); printf ("PASSED\n");
#endif #endif
return 0;
} }
#ifdef DEBUG #ifdef DEBUG
else printf ("SKIPPED\n");
printf ("SKIPPED\n");
#endif #endif
return 0; return 0;
} }
...@@ -25,87 +25,65 @@ do_test (void) ...@@ -25,87 +25,65 @@ do_test (void)
} }
#endif #endif
int static int
main () check_osxsave (void)
{ {
unsigned int eax, ebx, ecx, edx; unsigned int eax, ebx, ecx, edx;
if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) __cpuid (1, eax, ebx, ecx, edx);
goto skipped; return (ecx & bit_OSXSAVE) != 0;
}
/* 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_count (7, 0, eax, ebx, ecx, edx); int
main ()
{
unsigned int eax, ebx, ecx, edx;
if (!(ebx & bit_AVX512F)) if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
goto skipped; return 0;
/* Run AVX512 test only if host has ISA support. */
if (check_osxsave ()
&& (ebx & bit_AVX512F)
#ifdef AVX512VL #ifdef AVX512VL
if (!(ebx & bit_AVX512VL)) && (ebx & bit_AVX512VL)
goto skipped;
#endif #endif
#ifdef AVX512ER #ifdef AVX512ER
if (!(ebx & bit_AVX512ER)) && (ebx & bit_AVX512ER)
goto skipped;
#endif #endif
#ifdef AVX512CD #ifdef AVX512CD
if (!(ebx & bit_AVX512CD)) && (ebx & bit_AVX512CD)
goto skipped;
#endif #endif
#ifdef AVX512DQ #ifdef AVX512DQ
if (!(ebx & bit_AVX512DQ)) && (ebx & bit_AVX512DQ)
goto skipped;
#endif #endif
#ifdef AVX512BW #ifdef AVX512BW
if (!(ebx & bit_AVX512BW)) && (ebx & bit_AVX512BW)
goto skipped;
#endif #endif
#ifdef AVX512IFMA #ifdef AVX512IFMA
if (!(ebx & bit_AVX512IFMA)) && (ebx & bit_AVX512IFMA)
goto skipped;
#endif #endif
#ifdef AVX512VBMI #ifdef AVX512VBMI
if (!(ecx & bit_AVX512VBMI)) && (ecx & bit_AVX512VBMI)
goto skipped;
#endif #endif
#ifdef AVX5124FMAPS #ifdef AVX5124FMAPS
if (!(edx & bit_AVX5124FMAPS)) && (edx & bit_AVX5124FMAPS)
goto skipped;
#endif #endif
#ifdef AVX5124VNNIW #ifdef AVX5124VNNIW
if (!(edx & bit_AVX5124VNNIW)) && (edx & bit_AVX5124VNNIW)
goto skipped;
#endif #endif
#ifdef AVX512VPOPCNTDQ #ifdef AVX512VPOPCNTDQ
if (!(ecx & bit_AVX512VPOPCNTDQ)) && (ecx & bit_AVX512VPOPCNTDQ)
goto skipped;
#endif #endif
&& avx512f_os_support ())
if (!avx512f_os_support ()) {
goto skipped; DO_TEST ();
DO_TEST ();
#ifdef DEBUG #ifdef DEBUG
printf ("PASSED\n"); printf ("PASSED\n");
#endif #endif
return 0; return 0;
}
skipped:
#ifdef DEBUG #ifdef DEBUG
printf ("SKIPPED\n"); printf ("SKIPPED\n");
#endif #endif
......
...@@ -17,23 +17,21 @@ main () ...@@ -17,23 +17,21 @@ main ()
{ {
unsigned int eax, ebx, ecx, edx; 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; return 0;
__cpuid_count (7, 0, eax, ebx, ecx, edx);
/* Run BMI test only if host has BMI support. */ /* Run BMI test only if host has BMI support. */
if (ebx & bit_BMI) if (ebx & bit_BMI)
{ {
do_test (); do_test ();
#ifdef DEBUG #ifdef DEBUG
printf ("PASSED\n"); printf ("PASSED\n");
#endif #endif
return 0;
} }
#ifdef DEBUG #ifdef DEBUG
else printf ("SKIPPED\n");
printf ("SKIPPED\n");
#endif #endif
return 0; return 0;
} }
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "cpuid.h" #include "cpuid.h"
static void bmi2_test (void); static void bmi2_test (void);
...@@ -17,11 +16,9 @@ main () ...@@ -17,11 +16,9 @@ main ()
{ {
unsigned int eax, ebx, ecx, edx; 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; return 0;
__cpuid_count (7, 0, eax, ebx, ecx, edx);
/* Run BMI2 test only if host has BMI2 support. */ /* Run BMI2 test only if host has BMI2 support. */
if (ebx & bit_BMI2) if (ebx & bit_BMI2)
{ {
...@@ -29,11 +26,11 @@ main () ...@@ -29,11 +26,11 @@ main ()
#ifdef DEBUG #ifdef DEBUG
printf ("PASSED\n"); printf ("PASSED\n");
#endif #endif
return 0;
} }
#ifdef DEBUG #ifdef DEBUG
else printf ("SKIPPED\n");
printf ("SKIPPED\n");
#endif #endif
return 0; return 0;
} }
...@@ -26,6 +26,15 @@ static int xgetbv (unsigned x) ...@@ -26,6 +26,15 @@ static int xgetbv (unsigned x)
return eax; 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 int
main (int argc, const char **argv) main (int argc, const char **argv)
{ {
...@@ -35,7 +44,7 @@ main (int argc, const char **argv) ...@@ -35,7 +44,7 @@ main (int argc, const char **argv)
return NORUNRES; return NORUNRES;
/* Run MPX test only if host has MPX support. */ /* 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); mpx_test (argc, argv);
else else
{ {
......
...@@ -13,18 +13,19 @@ main () ...@@ -13,18 +13,19 @@ main ()
{ {
unsigned int eax, ebx, ecx, edx; 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); do_test ();
if (ebx & bit_RTM)
{
do_test ();
#ifdef DEBUG #ifdef DEBUG
printf ("PASSED\n"); printf ("PASSED\n");
#endif #endif
return 0; return 0;
}
} }
#ifdef DEBUG #ifdef DEBUG
printf ("SKIPPED\n"); printf ("SKIPPED\n");
#endif #endif
......
...@@ -15,19 +15,17 @@ main () ...@@ -15,19 +15,17 @@ main ()
{ {
unsigned int eax, ebx, ecx, edx; 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 SHA test only if host has SHA support. */ /* Run SHA test only if host has SHA support. */
if (ebx & bit_SHA) if (ebx & bit_SHA)
{ {
do_test (); do_test ();
#ifdef DEBUG #ifdef DEBUG
printf ("PASSED\n"); printf ("PASSED\n");
#endif #endif
return 0; return 0;
}
} }
#ifdef DEBUG #ifdef DEBUG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment