* 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
+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>
* gcc.target/i386/mpx/mpx-check.h (main): Use __get_cpuid_count
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 ();
#endif
return 0;
}
+
#ifdef DEBUG
printf ("SKIPPED\n");
#endif
-
return 0;
}
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;
}
}
#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
{
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;
}
#include <stdio.h>
#include <stdlib.h>
-
#include "cpuid.h"
static void bmi2_test (void);
{
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)
{
#ifdef DEBUG
printf ("PASSED\n");
#endif
+ return 0;
}
+
#ifdef DEBUG
- else
- printf ("SKIPPED\n");
+ printf ("SKIPPED\n");
#endif
-
return 0;
}
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)
{
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
{
{
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
{
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