+2017-08-04 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR target/81590
+ * gcc.target/i386/avx512-check.h: New file.
+ * gcc.target/i386/avx5124fmaps-check.h: Removed.
+ * gcc.target/i386/avx5124vnniw-check.h: Likewise.
+ * gcc.target/i386/avx512cd-check.h: Likewise.
+ * gcc.target/i386/avx512ifma-check.h: Likewise.
+ * gcc.target/i386/avx512vbmi-check.h: Likewise.
+ * gcc.target/i386/avx512vpopcntdq-check.h: Likewise.
+ * gcc.target/i386/avx512bw-check.h: Rewrite.
+ * gcc.target/i386/avx512dq-check.h: Likewise.
+ * gcc.target/i386/avx512er-check.h: Likewise.
+ * gcc.target/i386/avx512f-check.h: Likewise.
+ * gcc.target/i386/avx512vl-check.h: Likewise.
+ * gcc.target/i386/avx512f-helper.h: Include "avx512-check.h"
+ only.
+ (test_512): Removed.
+ (avx512*_test): Likewise.
+ * gcc.target/i386/avx512f-pr71559.c (TEST): Undef.
+
2017-08-04 Marek Polacek <polacek@redhat.com>
PR middle-end/81695
--- /dev/null
+#include <stdlib.h>
+#include "cpuid.h"
+#include "m512-check.h"
+#include "avx512f-os-support.h"
+
+#ifndef DO_TEST
+#define DO_TEST do_test
+#ifdef AVX512VL
+static void test_256 (void);
+static void test_128 (void);
+#else
+static void test_512 (void);
+#endif
+
+__attribute__ ((noinline))
+static void
+do_test (void)
+{
+#ifdef AVX512VL
+ test_256 ();
+ test_128 ();
+#else
+ test_512 ();
+#endif
+}
+#endif
+
+int
+main ()
+{
+ 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_count (7, 0, eax, ebx, ecx, edx);
+
+ if (!(ebx & bit_AVX512F))
+ goto skipped;
+
+#ifdef AVX512VL
+ if (!(ebx & bit_AVX512VL))
+ goto skipped;
+#endif
+
+#ifdef AVX512ER
+ if (!(ebx & bit_AVX512ER))
+ goto skipped;
+#endif
+
+#ifdef AVX512CD
+ if (!(ebx & bit_AVX512CD))
+ goto skipped;
+#endif
+
+#ifdef AVX512DQ
+ if (!(ebx & bit_AVX512DQ))
+ goto skipped;
+#endif
+
+#ifdef AVX512BW
+ if (!(ebx & bit_AVX512BW))
+ goto skipped;
+#endif
+
+#ifdef AVX512IFMA
+ if (!(ebx & bit_AVX512IFMA))
+ goto skipped;
+#endif
+
+#ifdef AVX512VBMI
+ if (!(ecx & bit_AVX512VBMI))
+ goto skipped;
+#endif
+
+#ifdef AVX5124FMAPS
+ if (!(edx & bit_AVX5124FMAPS))
+ goto skipped;
+#endif
+
+#ifdef AVX5124VNNIW
+ if (!(edx & bit_AVX5124VNNIW))
+ goto skipped;
+#endif
+
+#ifdef AVX512VPOPCNTDQ
+ if (!(ecx & bit_AVX512VPOPCNTDQ))
+ goto skipped;
+#endif
+
+ if (!avx512f_os_support ())
+ goto skipped;
+
+ DO_TEST ();
+
+#ifdef DEBUG
+ printf ("PASSED\n");
+#endif
+ return 0;
+
+skipped:
+#ifdef DEBUG
+ printf ("SKIPPED\n");
+#endif
+ return 0;
+}
+++ /dev/null
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx5124fmaps_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx5124fmaps_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run AVX512_4FMAPS test only if host has the support. */
- if ((ecx & bit_OSXSAVE) == (bit_OSXSAVE))
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((avx512f_os_support ()) && ((edx & bit_AVX5124FMAPS) == bit_AVX5124FMAPS))
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+++ /dev/null
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx5124vnniw_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx5124vnniw_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run AVX512_4VNNIW test only if host has the support. */
- if ((ecx & bit_OSXSAVE) == (bit_OSXSAVE))
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((avx512f_os_support ()) && ((edx & bit_AVX5124VNNIW) == bit_AVX5124VNNIW))
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512bw_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512bw_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run AVX512BW test only if host has AVX512BW support. */
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512BW) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+#define AVX512BW
+#define avx512bw_test test_512
+#include "avx512-check.h"
+++ /dev/null
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512cd_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512cd_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512CD) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512dq_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512dq_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run AVX512DQ test only if host has AVX512DQ support. */
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512DQ) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+#define AVX512DQ
+#define avx512dq_test test_512
+#include "avx512-check.h"
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512er_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512er_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512ER) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+#define AVX512ER
+#define avx512er_test test_512
+#include "avx512f-helper.h"
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512f_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512f_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run AVX512F test only if host has AVX512F support. */
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512F) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+#define avx512f_test test_512
+#include "avx512f-helper.h"
#ifndef AVX512F_HELPER_INCLUDED
#define AVX512F_HELPER_INCLUDED
-#if defined (AVX512F) && !defined (AVX512VL)
-#include "avx512f-check.h"
-#elif defined (AVX512ER) && !defined (AVX512VL)
-#include "avx512er-check.h"
-#elif defined (AVX512CD) && !defined (AVX512VL)
-#include "avx512cd-check.h"
-#elif defined (AVX512DQ) && !defined (AVX512VL)
-#include "avx512dq-check.h"
-#elif defined (AVX512BW) && !defined (AVX512VL)
-#include "avx512bw-check.h"
-#elif defined (AVX512IFMA) && !defined (AVX512VL)
-#include "avx512ifma-check.h"
-#elif defined (AVX512VBMI) && !defined (AVX512VL)
-#include "avx512vbmi-check.h"
-#elif defined (AVX5124FMAPS) && !defined (AVX512VL)
-#include "avx5124fmaps-check.h"
-#elif defined (AVX5124VNNIW) && !defined (AVX512VL)
-#include "avx5124vnniw-check.h"
-#elif defined (AVX512VPOPCNTDQ) && !defined (AVX512VL)
-#include "avx512vpopcntdq-check.h"
-#elif defined (AVX512VL)
-#include "avx512vl-check.h"
-#endif
+#include "avx512-check.h"
/* Macros expansion. */
#define CONCAT(a,b,c) a ## b ## c
#ifndef AVX512VL
#define AVX512F_LEN 512
#define AVX512F_LEN_HALF 256
-void test_512 ();
-#endif
-
-void test_512 ();
-void test_256 ();
-void test_128 ();
-
-#if defined (AVX512F) && !defined (AVX512VL)
-void
-avx512f_test (void) { test_512 (); }
-#elif defined (AVX512CD) && !defined (AVX512VL)
-void
-avx512cd_test (void) { test_512 (); }
-#elif defined (AVX512ER) && !defined (AVX512VL)
-void
-avx512er_test (void) { test_512 (); }
-#elif defined (AVX512DQ) && !defined (AVX512VL)
-void
-avx512dq_test (void) { test_512 (); }
-#elif defined (AVX512BW) && !defined (AVX512VL)
-void
-avx512bw_test (void) { test_512 (); }
-#elif defined (AVX512IFMA) && !defined (AVX512VL)
-void
-avx512ifma_test (void) { test_512 (); }
-#elif defined (AVX512VBMI) && !defined (AVX512VL)
-void
-avx512vbmi_test (void) { test_512 (); }
-#elif defined (AVX5124FMAPS) && !defined (AVX512VL)
-void
-avx5124fmaps_test (void) { test_512 (); }
-#elif defined (AVX5124VNNIW) && !defined (AVX512VL)
-void
-avx5124vnniw_test (void) { test_512 (); }
-#elif defined (AVX512VPOPCNTDQ) && !defined (AVX512VL)
-void
-avx512vpopcntdq_test (void) { test_512 (); }
-#elif defined (AVX512VL)
-void
-avx512vl_test (void) { test_256 (); test_128 (); }
#endif
#endif /* AVX512F_HELPER_INCLUDED */
/* { dg-options "-O2 -ftree-vectorize -mavx512f" } */
#include "avx512f-check.h"
+#undef TEST
#define PR71559_TEST avx512f_test
#include "sse2-pr71559.c"
+++ /dev/null
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512ifma_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512ifma_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512IFMA) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+++ /dev/null
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512vbmi_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512vbmi_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ecx & bit_AVX512VBMI) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512vl_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512vl_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run avx512vl test only if host has avx512vl support. */
- if (ecx & bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_AVX512VL) && avx512f_os_support ())
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}
+#define AVX512VL
+#define DO_TEST avx512vl_test
+static void DO_TEST (void);
+#include "avx512-check.h"
+++ /dev/null
-#include <stdlib.h>
-#include "cpuid.h"
-#include "m512-check.h"
-#include "avx512f-os-support.h"
-
-static void avx512vpopcntdq_test (void);
-
-static void __attribute__ ((noinline)) do_test (void)
-{
- avx512vpopcntdq_test ();
-}
-
-int
-main ()
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- /* Run AVX512_VPOPCNTDQ test only if host has the support. */
- if ((ecx & bit_OSXSAVE) == (bit_OSXSAVE))
- {
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((avx512f_os_support ()) && ((ecx & bit_AVX512VPOPCNTDQ) == bit_AVX512VPOPCNTDQ))
- {
- do_test ();
-#ifdef DEBUG
- printf ("PASSED\n");
-#endif
- return 0;
- }
-#ifdef DEBUG
- printf ("SKIPPED\n");
-#endif
- }
-#ifdef DEBUG
- else
- printf ("SKIPPED\n");
-#endif
-
- return 0;
-}