* [PATCH, i386]: Use __get_cpuid_count in testsuite ISA check headers
@ 2017-09-03 23:19 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2017-09-03 23:19 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 811 bytes --]
Hello!
Use __get_cpuid_count and introduce check_osxsave local function.
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.
Tested on x86_64-linux-gnu, committed to mainline SVN.
Uros.
[-- Attachment #2: t.diff.txt --]
[-- Type: text/plain, Size: 8065 bytes --]
Index: gcc.target/i386/adx-check.h
===================================================================
--- gcc.target/i386/adx-check.h (revision 251566)
+++ gcc.target/i386/adx-check.h (working copy)
@@ -13,16 +13,10 @@
{
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 @@
#endif
return 0;
}
+
#ifdef DEBUG
printf ("SKIPPED\n");
#endif
-
return 0;
}
Index: gcc.target/i386/avx2-check.h
===================================================================
--- gcc.target/i386/avx2-check.h (revision 251566)
+++ gcc.target/i386/avx2-check.h (working copy)
@@ -10,38 +10,35 @@
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 ();
+ do_test ();
#ifdef DEBUG
- printf ("PASSED\n");
+ printf ("PASSED\n");
#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
+ return 0;
}
+
#ifdef DEBUG
- else
- printf ("SKIPPED\n");
+ printf ("SKIPPED\n");
#endif
-
return 0;
}
Index: gcc.target/i386/avx512-check.h
===================================================================
--- gcc.target/i386/avx512-check.h (revision 251566)
+++ gcc.target/i386/avx512-check.h (working copy)
@@ -25,87 +25,65 @@
}
#endif
+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))
- goto skipped;
+ if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
+ return 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);
-
- if (!(ebx & bit_AVX512F))
- goto skipped;
-
+ /* 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
Index: gcc.target/i386/bmi-check.h
===================================================================
--- gcc.target/i386/bmi-check.h (revision 251566)
+++ gcc.target/i386/bmi-check.h (working copy)
@@ -17,23 +17,21 @@
{
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;
}
Index: gcc.target/i386/bmi2-check.h
===================================================================
--- gcc.target/i386/bmi2-check.h (revision 251566)
+++ gcc.target/i386/bmi2-check.h (working copy)
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
-
#include "cpuid.h"
static void bmi2_test (void);
@@ -17,11 +16,9 @@
{
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 @@
#ifdef DEBUG
printf ("PASSED\n");
#endif
+ return 0;
}
+
#ifdef DEBUG
- else
- printf ("SKIPPED\n");
+ printf ("SKIPPED\n");
#endif
-
return 0;
}
Index: gcc.target/i386/mpx/mpx-check.h
===================================================================
--- gcc.target/i386/mpx/mpx-check.h (revision 251627)
+++ gcc.target/i386/mpx/mpx-check.h (working copy)
@@ -26,6 +26,15 @@
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 @@
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
{
Index: gcc.target/i386/rtm-check.h
===================================================================
--- gcc.target/i386/rtm-check.h (revision 251566)
+++ gcc.target/i386/rtm-check.h (working copy)
@@ -13,18 +13,19 @@
{
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
Index: gcc.target/i386/sha-check.h
===================================================================
--- gcc.target/i386/sha-check.h (revision 251566)
+++ gcc.target/i386/sha-check.h (working copy)
@@ -15,19 +15,17 @@
{
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 SHA test only if host has SHA support. */
+ if (ebx & bit_SHA)
{
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- /* Run SHA test only if host has SHA support. */
- if (ebx & bit_SHA)
- {
- do_test ();
+ do_test ();
#ifdef DEBUG
- printf ("PASSED\n");
+ printf ("PASSED\n");
#endif
- return 0;
- }
+ return 0;
}
#ifdef DEBUG
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-03 23:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-03 23:19 [PATCH, i386]: Use __get_cpuid_count in testsuite ISA check headers Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).