From 945b6e16e23ede6f80ea67634b14e3fd07f51cce Mon Sep 17 00:00:00 2001 From: Andrew Senkevich Date: Fri, 3 Mar 2017 16:55:31 +0000 Subject: [PATCH] avx512vpopcntdq-check.h: New. * 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 --- gcc/testsuite/ChangeLog | 9 +++ .../gcc.target/i386/avx512f-helper.h | 5 ++ .../gcc.target/i386/avx512vpopcntdq-check.h | 47 +++++++++++++++ .../i386/avx512vpopcntdq-vpopcntd-1.c | 57 +++++++++++++++++++ .../i386/avx512vpopcntdq-vpopcntq-1.c | 57 +++++++++++++++++++ gcc/testsuite/gcc.target/i386/i386.exp | 13 +++++ 6 files changed, 188 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/avx512vpopcntdq-check.h create mode 100644 gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a0e483078c1..f4333095a1b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2017-03-03 Andrew Senkevich + + * 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 * gcc.target/mips/pr68273.c (dg-final): Match SImode registers only for diff --git a/gcc/testsuite/gcc.target/i386/avx512f-helper.h b/gcc/testsuite/gcc.target/i386/avx512f-helper.h index 6aca0d6bdc2..ef4661a3453 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-helper.h +++ b/gcc/testsuite/gcc.target/i386/avx512f-helper.h @@ -26,6 +26,8 @@ #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 @@ -144,6 +146,9 @@ 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 (); } diff --git a/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-check.h b/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-check.h new file mode 100644 index 00000000000..179548bf8cb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-check.h @@ -0,0 +1,47 @@ +#include +#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; +} diff --git a/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c b/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c new file mode 100644 index 00000000000..d9faf0adc4e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntd-1.c @@ -0,0 +1,57 @@ +/* { 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 (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c b/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c new file mode 100644 index 00000000000..5a628210f63 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vpopcntdq-vpopcntq-1.c @@ -0,0 +1,57 @@ +/* { 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 (); +} diff --git a/gcc/testsuite/gcc.target/i386/i386.exp b/gcc/testsuite/gcc.target/i386/i386.exp index d06c0d93b44..eae253192ad 100644 --- a/gcc/testsuite/gcc.target/i386/i386.exp +++ b/gcc/testsuite/gcc.target/i386/i386.exp @@ -408,6 +408,19 @@ proc check_effective_target_avx5124vnniw { } { } "-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 { -- 2.30.2