* gcc.target/i386/avx512vpopcntdq-check.h: New.
* gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c: Ditto.
* gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c: Ditto.
* gcc.target/i386/avx512f-helper.h: Add avx512vpopcntdq-check.h.
* gcc.target/i386/i386.exp
(check_effective_target_avx512vpopcntdq): New.
From-SVN: r245879
+2017-03-03 Andrew Senkevich <andrew.senkevich@intel.com>
+
+ * gcc.target/i386/avx512vpopcntdq-check.h: New.
+ * gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c: Ditto.
+ * gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c: Ditto.
+ * gcc.target/i386/avx512f-helper.h: Add avx512vpopcntdq-check.h.
+ * gcc.target/i386/i386.exp
+ (check_effective_target_avx512vpopcntdq): New.
+
2017-03-03 Toma Tabacu <toma.tabacu@imgtec.com>
* gcc.target/mips/pr68273.c (dg-final): Match SImode registers only for
#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
#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 (); }
--- /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;
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -mavx512vpopcntdq" } */
+/* { dg-require-effective-target avx512vpopcntdq } */
+
+#define AVX512VPOPCNTDQ
+#include "avx512f-helper.h"
+
+#define SIZE (AVX512F_LEN / 32)
+
+#include "avx512f-mask-type.h"
+
+#define TYPE int
+
+static int
+compute_popcnt (TYPE v)
+{
+ int ret;
+ int i;
+
+ ret = 0;
+ for (i = 0; i < sizeof(v) * 8; i++)
+ if ((v & ((TYPE)1 << (TYPE) i)))
+ ret++;
+
+ return ret;
+}
+
+void
+TEST (void)
+{
+ UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3, src, src0;
+ MASK_TYPE mask = MASK_VALUE;
+ TYPE res_ref[SIZE];
+ src.x = _mm512_set1_epi8 (0x3D);
+ int i;
+
+ for (i = 0; i < SIZE; i++)
+ {
+ res_ref[i] = compute_popcnt (src.a[i]);
+ src0.a[i] = DEFAULT_VALUE;
+ }
+
+ res1.x = INTRINSIC (_popcnt_epi32) (src.x);
+ res2.x = INTRINSIC (_mask_popcnt_epi32) (src.x, mask, src0.x);
+ res3.x = INTRINSIC (_maskz_popcnt_epi32) (mask, src.x);
+
+ if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
+ abort ();
+
+ MASK_MERGE (i_d) (res_ref, mask, SIZE);
+ if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
+ abort ();
+
+ MASK_ZERO (i_d) (res_ref, mask, SIZE);
+ if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
+ abort ();
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -mavx512vpopcntdq" } */
+/* { dg-require-effective-target avx512vpopcntdq } */
+
+#define AVX512VPOPCNTDQ
+#include "avx512f-helper.h"
+
+#define SIZE (AVX512F_LEN / 64)
+
+#include "avx512f-mask-type.h"
+
+#define TYPE long long
+
+static int
+compute_popcnt (TYPE v)
+{
+ int ret;
+ int i;
+
+ ret = 0;
+ for (i = 0; i < sizeof(v) * 8; i++)
+ if ((v & ((TYPE)1 << (TYPE) i)))
+ ret++;
+
+ return ret;
+}
+
+void
+TEST (void)
+{
+ UNION_TYPE (AVX512F_LEN, i_q) res1, res2, res3, src, src0;
+ MASK_TYPE mask = MASK_VALUE;
+ TYPE res_ref[SIZE];
+ src.x = _mm512_set1_epi8 (0x3D);
+ int i;
+
+ for (i = 0; i < SIZE; i++)
+ {
+ res_ref[i] = compute_popcnt (src.a[i]);
+ src0.a[i] = DEFAULT_VALUE;
+ }
+
+ res1.x = INTRINSIC (_popcnt_epi64) (src.x);
+ res2.x = INTRINSIC (_mask_popcnt_epi64) (src.x, mask, src0.x);
+ res3.x = INTRINSIC (_maskz_popcnt_epi64) (mask, src.x);
+
+ if (UNION_CHECK (AVX512F_LEN, i_q) (res1, res_ref))
+ abort ();
+
+ MASK_MERGE (i_q) (res_ref, mask, SIZE);
+ if (UNION_CHECK (AVX512F_LEN, i_q) (res2, res_ref))
+ abort ();
+
+ MASK_ZERO (i_q) (res_ref, mask, SIZE);
+ if (UNION_CHECK (AVX512F_LEN, i_q) (res3, res_ref))
+ abort ();
+}
} "-mavx5124vnniw" ]
}
+# Return 1 if avx512_vpopcntdq instructions can be compiled.
+proc check_effective_target_avx512vpopcntdq { } {
+ return [check_no_compiler_messages avx512vpopcntdq object {
+ typedef int __v16si __attribute__ ((__vector_size__ (64)));
+
+ __v16si
+ _mm512_popcnt_epi32 (__v16si __A)
+ {
+ return (__v16si) __builtin_ia32_vpopcountd_v16si ((__v16si) __A);
+ }
+ } "-mavx512vpopcntdq" ]
+}
+
# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {