From 96d5c6dcf6b8ec0ad34a8208fc6d82df3ce20e2a Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 5 Aug 2019 10:00:30 +0200 Subject: [PATCH] re PR target/91341 (Missing AVX Intrinsics: load/store u2) PR target/91341 * config/i386/avxintrin.h (_mm256_loadu2_m128, _mm256_storeu2_m128, _mm256_loadu2_m128d, _mm256_storeu2_m128d, _mm256_loadu2_m128i, _mm256_storeu2_m128i): New function. * gcc.target/i386/avx-loadu2-m128-1.c: New test. * gcc.target/i386/avx-loadu2-m128-2.c: New test. * gcc.target/i386/avx-loadu2-m128d-1.c: New test. * gcc.target/i386/avx-loadu2-m128d-2.c: New test. * gcc.target/i386/avx-loadu2-m128i-1.c: New test. * gcc.target/i386/avx-loadu2-m128i-2.c: New test. * gcc.target/i386/avx-storeu2-m128-1.c: New test. * gcc.target/i386/avx-storeu2-m128-2.c: New test. * gcc.target/i386/avx-storeu2-m128d-1.c: New test. * gcc.target/i386/avx-storeu2-m128d-2.c: New test. * gcc.target/i386/avx-storeu2-m128i-1.c: New test. * gcc.target/i386/avx-storeu2-m128i-2.c: New test. From-SVN: r274109 --- gcc/ChangeLog | 7 ++++ gcc/config/i386/avxintrin.h | 42 +++++++++++++++++++ gcc/testsuite/ChangeLog | 16 +++++++ .../gcc.target/i386/avx-loadu2-m128-1.c | 12 ++++++ .../gcc.target/i386/avx-loadu2-m128-2.c | 17 ++++++++ .../gcc.target/i386/avx-loadu2-m128d-1.c | 12 ++++++ .../gcc.target/i386/avx-loadu2-m128d-2.c | 17 ++++++++ .../gcc.target/i386/avx-loadu2-m128i-1.c | 12 ++++++ .../gcc.target/i386/avx-loadu2-m128i-2.c | 17 ++++++++ .../gcc.target/i386/avx-storeu2-m128-1.c | 12 ++++++ .../gcc.target/i386/avx-storeu2-m128-2.c | 18 ++++++++ .../gcc.target/i386/avx-storeu2-m128d-1.c | 12 ++++++ .../gcc.target/i386/avx-storeu2-m128d-2.c | 18 ++++++++ .../gcc.target/i386/avx-storeu2-m128i-1.c | 12 ++++++ .../gcc.target/i386/avx-storeu2-m128i-2.c | 18 ++++++++ 15 files changed, 242 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/avx-loadu2-m128-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-loadu2-m128-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-storeu2-m128-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-storeu2-m128-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-2.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-1.c create mode 100644 gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2de2e652357..121da52b33c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-08-05 Jakub Jelinek + + PR target/91341 + * config/i386/avxintrin.h (_mm256_loadu2_m128, _mm256_storeu2_m128, + _mm256_loadu2_m128d, _mm256_storeu2_m128d, _mm256_loadu2_m128i, + _mm256_storeu2_m128i): New function. + 2019-08-05 Kito Cheng * config/riscv/riscv.c (riscv_promote_function_mode): New. diff --git a/gcc/config/i386/avxintrin.h b/gcc/config/i386/avxintrin.h index 29115a11a0d..18c0711a8ad 100644 --- a/gcc/config/i386/avxintrin.h +++ b/gcc/config/i386/avxintrin.h @@ -1520,6 +1520,48 @@ _mm256_setr_m128i (__m128i __L, __m128i __H) return _mm256_set_m128i (__H, __L); } +extern __inline __m256 __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_loadu2_m128 (float const *__PH, float const *__PL) +{ + return _mm256_insertf128_ps (_mm256_castps128_ps256 (_mm_loadu_ps (__PL)), + _mm_loadu_ps (__PH), 1); +} + +extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_storeu2_m128 (float *__PH, float *__PL, __m256 __A) +{ + _mm_storeu_ps (__PL, _mm256_castps256_ps128 (__A)); + _mm_storeu_ps (__PH, _mm256_extractf128_ps (__A, 1)); +} + +extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_loadu2_m128d (double const *__PH, double const *__PL) +{ + return _mm256_insertf128_pd (_mm256_castpd128_pd256 (_mm_loadu_pd (__PL)), + _mm_loadu_pd (__PH), 1); +} + +extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_storeu2_m128d (double *__PH, double *__PL, __m256d __A) +{ + _mm_storeu_pd (__PL, _mm256_castpd256_pd128 (__A)); + _mm_storeu_pd (__PH, _mm256_extractf128_pd (__A, 1)); +} + +extern __inline __m256i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_loadu2_m128i (__m128i_u const *__PH, __m128i_u const *__PL) +{ + return _mm256_insertf128_si256 (_mm256_castsi128_si256 (_mm_loadu_si128 (__PL)), + _mm_loadu_si128 (__PH), 1); +} + +extern __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_storeu2_m128i (__m128i_u *__PH, __m128i_u *__PL, __m256i __A) +{ + _mm_storeu_si128 (__PL, _mm256_castsi256_si128 (__A)); + _mm_storeu_si128 (__PH, _mm256_extractf128_si256 (__A, 1)); +} + #ifdef __DISABLE_AVX__ #undef __DISABLE_AVX__ #pragma GCC pop_options diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8fe569ac176..e19f136370b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2019-08-05 Jakub Jelinek + + PR target/91341 + * gcc.target/i386/avx-loadu2-m128-1.c: New test. + * gcc.target/i386/avx-loadu2-m128-2.c: New test. + * gcc.target/i386/avx-loadu2-m128d-1.c: New test. + * gcc.target/i386/avx-loadu2-m128d-2.c: New test. + * gcc.target/i386/avx-loadu2-m128i-1.c: New test. + * gcc.target/i386/avx-loadu2-m128i-2.c: New test. + * gcc.target/i386/avx-storeu2-m128-1.c: New test. + * gcc.target/i386/avx-storeu2-m128-2.c: New test. + * gcc.target/i386/avx-storeu2-m128d-1.c: New test. + * gcc.target/i386/avx-storeu2-m128d-2.c: New test. + * gcc.target/i386/avx-storeu2-m128i-1.c: New test. + * gcc.target/i386/avx-storeu2-m128i-2.c: New test. + 2019-08-05 Kito Cheng * gcc.target/riscv/promote-type-for-libcall.c: New. diff --git a/gcc/testsuite/gcc.target/i386/avx-loadu2-m128-1.c b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128-1.c new file mode 100644 index 00000000000..d5b5ad251f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-final { scan-assembler "\tvmovups\t" } } */ +/* { dg-final { scan-assembler "\tvinsertf128\t" } } */ + +#include + +__m256 +foo (float const *hi, float const *lo) +{ + return _mm256_loadu2_m128 (hi, lo); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-loadu2-m128-2.c b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128-2.c new file mode 100644 index 00000000000..b962c2c45ed --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-require-effective-target avx } */ + +#include "avx-check.h" + +static void +avx_test (void) +{ + union256 u; + float e[8] = { 1.5f, -9.5f, 13.25f, -24.75f, -18.75f, 12.0f, 0.0f, 9.0f }; + float f[8] = { -24.75f, -18.75f, 12.0f, 0.0f, -9.5f, 13.25f, -24.75f, -18.75f }; + + u.x = _mm256_loadu2_m128 (e + 1, e + 3); + if (check_union256 (u, f)) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-1.c b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-1.c new file mode 100644 index 00000000000..3cdd497a207 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-final { scan-assembler "\tvmovupd\t" } } */ +/* { dg-final { scan-assembler "\tvinsertf128\t" } } */ + +#include + +__m256d +foo (double const *hi, double const *lo) +{ + return _mm256_loadu2_m128d (hi, lo); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-2.c b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-2.c new file mode 100644 index 00000000000..d342fdc6f62 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-require-effective-target avx } */ + +#include "avx-check.h" + +static void +avx_test (void) +{ + union256d u; + double e[8] = { 1.5, -9.5, 13.25, -24.75, -18.75, 12.0, 0.0, 9.0 }; + double f[4] = { 12.0, 0.0, -9.5, 13.25 }; + + u.x = _mm256_loadu2_m128d (e + 1, e + 5); + if (check_union256d (u, f)) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-1.c b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-1.c new file mode 100644 index 00000000000..32d5444ed13 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-final { scan-assembler "\tvmovdqu\t" } } */ +/* { dg-final { scan-assembler "\tvinsert\[fi]128\t" } } */ + +#include + +__m256i +foo (__m128i_u const *hi, __m128i_u const *lo) +{ + return _mm256_loadu2_m128i (hi, lo); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-2.c b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-2.c new file mode 100644 index 00000000000..e090b9858a9 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-2.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-require-effective-target avx } */ + +#include "avx-check.h" + +static void +avx_test (void) +{ + union256i_d u; + int e[8] = { 1, -9, 13, -24, -18, 12, 0, 9 }; + int f[8] = { -24, -18, 12, 0, -9, 13, -24, -18 }; + + u.x = _mm256_loadu2_m128i ((__m128i_u *) (e + 1), (__m128i_u *) (e + 3)); + if (check_union256i_d (u, f)) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-storeu2-m128-1.c b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128-1.c new file mode 100644 index 00000000000..cca79c5ad5b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-final { scan-assembler "\tvmovups\t" } } */ +/* { dg-final { scan-assembler "\tvextractf128\t" } } */ + +#include + +void +foo (float *hi, float *lo, __m256 a) +{ + _mm256_storeu2_m128 (hi, lo, a); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-storeu2-m128-2.c b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128-2.c new file mode 100644 index 00000000000..81c823aefcf --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-require-effective-target avx } */ + +#include "avx-check.h" + +static void +avx_test (void) +{ + float e[12] = { -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f }; + float f[12] = { -1.0f, -18.75f, 12.0f, 0.0f, 9.0f, -1.0f, 1.5f, -9.5f, 13.25f, -24.75f, -1.0f, -1.0f }; + int i; + __m256 x = _mm256_set_ps (1.5f, -9.5f, 13.25f, -24.75f, -18.75f, 12.0f, 0.0f, 9.0f); + _mm256_storeu2_m128 (e + 1, e + 6, x); + for (i = 0; i < 12; i++) + if (e[i] != f[i]) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-1.c b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-1.c new file mode 100644 index 00000000000..01cb2231f62 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-final { scan-assembler "\tvmovup\[sd]\t" } } */ +/* { dg-final { scan-assembler "\tvextractf128\t" } } */ + +#include + +void +foo (double *hi, double *lo, __m256d a) +{ + _mm256_storeu2_m128d (hi, lo, a); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-2.c b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-2.c new file mode 100644 index 00000000000..37c23c226f8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-require-effective-target avx } */ + +#include "avx-check.h" + +static void +avx_test (void) +{ + double e[8] = { -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0 }; + double f[8] = { -1.0, 13.25, -24.75, -1.0, 1.5, -9.5, -1.0, -1.0 }; + int i; + __m256d x = _mm256_set_pd (1.5, -9.5, 13.25, -24.75); + _mm256_storeu2_m128d (e + 1, e + 4, x); + for (i = 0; i < 8; i++) + if (e[i] != f[i]) + abort (); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-1.c b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-1.c new file mode 100644 index 00000000000..bf2e72a3577 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-final { scan-assembler "\tvmov(dqu|ups)\t" } } */ +/* { dg-final { scan-assembler "\tvextract\[if]128\t" } } */ + +#include + +void +foo (__m128i_u *hi, __m128i_u *lo, __m256i a) +{ + _mm256_storeu2_m128i (hi, lo, a); +} diff --git a/gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-2.c b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-2.c new file mode 100644 index 00000000000..dd1825f8778 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-2.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx" } */ +/* { dg-require-effective-target avx } */ + +#include "avx-check.h" + +static void +avx_test (void) +{ + int e[12] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + int f[12] = { -1, -18, 12, 0, 9, -1, 1, -9, 13, -24, -1, -1 }; + int i; + __m256i x = _mm256_set_epi32 (1, -9, 13, -24, -18, 12, 0, 9); + _mm256_storeu2_m128i ((__m128i_u *) (e + 1), (__m128i_u *) (e + 6), x); + for (i = 0; i < 12; i++) + if (e[i] != f[i]) + abort (); +} -- 2.30.2