From 17ecc36ec4753ff04791ee660217fd62b092b3eb Mon Sep 17 00:00:00 2001 From: Julia Koval Date: Fri, 8 Dec 2017 06:04:26 +0100 Subject: [PATCH] Enable VAES support [2/5] gcc/ * config.gcc: Add vaesintrin.h. * config/i386/i386-builtin-types.def (V64QI_FTYPE_V64QI_V64QI): New type. * config/i386/i386-builtin.def (__builtin_ia32_vaesdec_v16qi, __builtin_ia32_vaesdec_v32qi, __builtin_ia32_vaesdec_v64qi): New builtins. * config/i386/i386.c (ix86_expand_args_builtin): Handle new type. * config/i386/immintrin.h: Include vaesintrin.h. * config/i386/sse.md (vaesdec_): New pattern. * config/i386/vaesintrin.h (_mm256_aesdec_epi128, _mm512_aesdec_epi128, _mm_aesdec_epi128): New intrinsics. gcc/testsuite/ * gcc.target/i386/avx512-check.h: Handle bit_VAES. * gcc.target/i386/avx512f-aesdec-2.c: New test. * gcc.target/i386/avx512fvl-vaes-1.c: Ditto. * gcc.target/i386/avx512vl-aesdec-2.c: Ditto. * gcc.target/i386/i386.exp (check_effective_target_avx512vaes): New. From-SVN: r255495 --- gcc/ChangeLog | 12 +++ gcc/config/i386/avx512vnniintrin.h | 27 +++++++ gcc/config/i386/avx512vnnivlintrin.h | 49 +++++++++++++ gcc/testsuite/ChangeLog | 8 ++ .../gcc.target/i386/avx512f-vnni-1.c | 7 ++ .../gcc.target/i386/avx512f-vpdpbusds-2.c | 73 +++++++++++++++++++ .../gcc.target/i386/avx512vl-vnni-1.c | 15 ++++ .../gcc.target/i386/avx512vl-vpdpbusds-2.c | 16 ++++ 8 files changed, 207 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/avx512f-vpdpbusds-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx512vl-vpdpbusds-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bea643d6285..3de4b428ae9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2017-12-08 Julia Koval + + * config.gcc: Add vaesintrin.h. + * config/i386/i386-builtin-types.def (V64QI_FTYPE_V64QI_V64QI): New type. + * config/i386/i386-builtin.def (__builtin_ia32_vaesdec_v16qi, + __builtin_ia32_vaesdec_v32qi, __builtin_ia32_vaesdec_v64qi): New builtins. + * config/i386/i386.c (ix86_expand_args_builtin): Handle new type. + * config/i386/immintrin.h: Include vaesintrin.h. + * config/i386/sse.md (vaesdec_): New pattern. + * config/i386/vaesintrin.h (_mm256_aesdec_epi128, _mm512_aesdec_epi128, + _mm_aesdec_epi128): New intrinsics. + 2017-12-07 Sandra Loosemore * config/nios2/nios2.md (ldio): Add splitter for memory diff --git a/gcc/config/i386/avx512vnniintrin.h b/gcc/config/i386/avx512vnniintrin.h index 9a48e28b732..c9842f3833f 100644 --- a/gcc/config/i386/avx512vnniintrin.h +++ b/gcc/config/i386/avx512vnniintrin.h @@ -58,6 +58,33 @@ _mm512_maskz_dpbusd_epi32 (__mmask16 __A, __m512i __B, __m512i __C, return (__m512i)__builtin_ia32_vpdpbusd_v16si_maskz ((__v16si)__B, (__v16si) __C, (__v16si) __D, (__mmask16)__A); } + +extern __inline __m512i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_dpbusds_epi32 (__m512i __A, __m512i __B, __m512i __C) +{ + return (__m512i) __builtin_ia32_vpdpbusds_v16si ((__v16si)__A, (__v16si) __B, + (__v16si) __C); +} + +extern __inline __m512i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_mask_dpbusds_epi32 (__m512i __A, __mmask16 __B, __m512i __C, + __m512i __D) +{ + return (__m512i)__builtin_ia32_vpdpbusds_v16si_mask ((__v16si)__A, + (__v16si) __C, (__v16si) __D, (__mmask16)__B); +} + +extern __inline __m512i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_maskz_dpbusds_epi32 (__mmask16 __A, __m512i __B, __m512i __C, + __m512i __D) +{ + return (__m512i)__builtin_ia32_vpdpbusds_v16si_maskz ((__v16si)__B, + (__v16si) __C, (__v16si) __D, (__mmask16)__A); +} + #ifdef __DISABLE_AVX512VNNI__ #undef __DISABLE_AVX512VNNI__ #pragma GCC pop_options diff --git a/gcc/config/i386/avx512vnnivlintrin.h b/gcc/config/i386/avx512vnnivlintrin.h index b5fea902ad2..621f0aceb71 100644 --- a/gcc/config/i386/avx512vnnivlintrin.h +++ b/gcc/config/i386/avx512vnnivlintrin.h @@ -82,6 +82,55 @@ _mm_maskz_dpbusd_epi32 (__mmask8 __A, __m128i __B, __m128i __C, __m128i __D) (__v4si) __C, (__v4si) __D, (__mmask8)__A); } +extern __inline __m256i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_dpbusds_epi32 (__m256i __A, __m256i __B, __m256i __C) +{ + return (__m256i) __builtin_ia32_vpdpbusds_v8si ((__v8si)__A, (__v8si) __B, + (__v8si) __C); +} + +extern __inline __m256i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_mask_dpbusds_epi32 (__m256i __A, __mmask8 __B, __m256i __C, __m256i __D) +{ + return (__m256i)__builtin_ia32_vpdpbusds_v8si_mask ((__v8si)__A, + (__v8si) __C, (__v8si) __D, (__mmask8)__B); +} + +extern __inline __m256i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_maskz_dpbusds_epi32 (__mmask8 __A, __m256i __B, __m256i __C, + __m256i __D) +{ + return (__m256i)__builtin_ia32_vpdpbusds_v8si_maskz ((__v8si)__B, + (__v8si) __C, (__v8si) __D, (__mmask8)__A); +} + +extern __inline __m128i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_dpbusds_epi32 (__m128i __A, __m128i __B, __m128i __C) +{ + return (__m128i) __builtin_ia32_vpdpbusds_v4si ((__v4si)__A, (__v4si) __B, + (__v4si) __C); +} + +extern __inline __m128i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_mask_dpbusds_epi32 (__m128i __A, __mmask8 __B, __m128i __C, __m128i __D) +{ + return (__m128i)__builtin_ia32_vpdpbusds_v4si_mask ((__v4si)__A, + (__v4si) __C, (__v4si) __D, (__mmask8)__B); +} + +extern __inline __m128i +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm_maskz_dpbusds_epi32 (__mmask8 __A, __m128i __B, __m128i __C, __m128i __D) +{ + return (__m128i)__builtin_ia32_vpdpbusds_v4si_maskz ((__v4si)__B, + (__v4si) __C, (__v4si) __D, (__mmask8)__A); +} + #ifdef __DISABLE_AVX512VNNIVL__ #undef __DISABLE_AVX512VNNIVL__ #pragma GCC pop_options diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9d4f1c81609..3020f51df66 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-12-08 Julia Koval + + * gcc.target/i386/avx512-check.h: Handle bit_VAES. + * gcc.target/i386/avx512f-aesdec-2.c: New test. + * gcc.target/i386/avx512fvl-vaes-1.c: Ditto. + * gcc.target/i386/avx512vl-aesdec-2.c: Ditto. + * gcc.target/i386/i386.exp (check_effective_target_avx512vaes): New. + 2017-12-07 Sandra Loosemore * gcc.target/nios2/const-addr-1.c: New. diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vnni-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vnni-1.c index 32fc8a4794d..b4b6d83d3a9 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vnni-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vnni-1.c @@ -3,6 +3,9 @@ /* { dg-final { scan-assembler-times "vpdpbusd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpdpbusd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpdpbusd\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+\[^\n\r]*%zmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%zmm\[0-9\]+\[^\\n\\r]*%zmm\[0-9\]+\[^\\n\\r\]*%zmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ #include @@ -18,4 +21,8 @@ avx512f_test (void) x = _mm512_mask_dpbusd_epi32 (x, m16, y, z); x = _mm512_maskz_dpbusd_epi32 (m16, x, y, z); + x = _mm512_dpbusds_epi32 (x, y, z); + x = _mm512_mask_dpbusds_epi32 (x, m16, y, z); + x = _mm512_maskz_dpbusds_epi32 (m16, x, y, z); + } diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpdpbusds-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpdpbusds-2.c new file mode 100644 index 00000000000..ac449040aec --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpdpbusds-2.c @@ -0,0 +1,73 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f -mavx512vnni" } */ +/* { dg-require-effective-target avx512f } */ +/* { dg-require-effective-target avx512vnni } */ + +#define AVX512F + +#define AVX512VNNI +#include "avx512f-helper.h" + +#define SIZE (AVX512F_LEN / 8) +#define SIZE_RES (AVX512F_LEN / 32) + +#include "avx512f-mask-type.h" + +static void +CALC (int *r, int *dst, unsigned char *s1, char *s2) +{ + short tempres[SIZE]; + for (int i = 0; i < SIZE; i++) { + tempres[i] = ((unsigned short)(s1[i]) * (short)(s2[i])); + } + for (int i = 0; i < SIZE_RES; i++) { + long long test = (long long) dst[i] + tempres[i*4] + tempres[i*4 + 1] + tempres[i*4 + 2] + tempres[i*4 + 3]; + long long max_int = 0x7FFFFFFF; + if (test > max_int) + test = 0x7FFFFFFF; + r[i] = test; + } +} + +void +TEST (void) +{ + int i; + UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3; + UNION_TYPE (AVX512F_LEN, i_ub) src1; + UNION_TYPE (AVX512F_LEN, i_b) src2; + MASK_TYPE mask = MASK_VALUE; + int res_ref[SIZE_RES], res_ref2[SIZE_RES]; + + for (i = 0; i < SIZE; i++) + { + int sign = i % 2 ? 1 : -1; + src1.a[i] = 10 + 3*i*i + sign; + src2.a[i] = sign*10*i*i; + } + + for (i = 0; i < SIZE_RES; i++) + { + res1.a[i] = 0x7FFFFFFF; + res2.a[i] = DEFAULT_VALUE; + res3.a[i] = DEFAULT_VALUE; + } + + CALC (res_ref, res1.a, src1.a, src2.a); + CALC (res_ref2, res2.a, src1.a, src2.a); + + res1.x = INTRINSIC (_dpbusds_epi32) (res1.x, src1.x, src2.x); + res2.x = INTRINSIC (_mask_dpbusds_epi32) (res2.x, mask, src1.x, src2.x); + res3.x = INTRINSIC (_maskz_dpbusds_epi32) (mask, res3.x, src1.x, src2.x); + + if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref)) + abort (); + + MASK_MERGE (i_d) (res_ref2, mask, SIZE_RES); + if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref2)) + abort (); + + MASK_ZERO (i_d) (res_ref2, mask, SIZE_RES); + if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref2)) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vnni-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vnni-1.c index bc18c632d4b..058c082cff1 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-vnni-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vnni-1.c @@ -6,6 +6,13 @@ /* { dg-final { scan-assembler-times "vpdpbusd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpdpbusd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpdpbusd\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+\[^\n\r]*%ymm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\[^\\n\\r]*%ymm\[0-9\]+\[^\\n\\r\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+\[^\n\r]*%xmm\[0-9\]+(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ +/* { dg-final { scan-assembler-times "vpdpbusds\[ \\t\]+\[^\{\n\]*%xmm\[0-9\]+\[^\\n\\r]*%xmm\[0-9\]+\[^\\n\\r\]*%xmm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ + #include @@ -24,4 +31,12 @@ avx512f_test (void) x_ = _mm_mask_dpbusd_epi32 (x_, m, y_, z_); x_ = _mm_maskz_dpbusd_epi32 (m, x_, y_, z_); + x = _mm256_dpbusds_epi32 (x, y, z); + x = _mm256_mask_dpbusds_epi32 (x, m, y, z); + x = _mm256_maskz_dpbusds_epi32 (m, x, y, z); + + x_ = _mm_dpbusds_epi32 (x_, y_, z_); + x_ = _mm_mask_dpbusds_epi32 (x_, m, y_, z_); + x_ = _mm_maskz_dpbusds_epi32 (m, x_, y_, z_); + } diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpdpbusds-2.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpdpbusds-2.c new file mode 100644 index 00000000000..cb5856d7ee7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpdpbusds-2.c @@ -0,0 +1,16 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512vnni -mavx512vl" } */ +/* { dg-require-effective-target avx512vl } */ +/* { dg-require-effective-target avx512vnni } */ + +#define AVX512VL +#define AVX512F_LEN 256 +#define AVX512F_LEN_HALF 128 +#include "avx512f-vpdpbusds-2.c" + +#undef AVX512F_LEN +#undef AVX512F_LEN_HALF + +#define AVX512F_LEN 128 +#define AVX512F_LEN_HALF 128 +#include "avx512f-vpdpbusds-2.c" -- 2.30.2