re PR target/91341 (Missing AVX Intrinsics: load/store u2)
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 Aug 2019 08:00:30 +0000 (10:00 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 Aug 2019 08:00:30 +0000 (10:00 +0200)
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

15 files changed:
gcc/ChangeLog
gcc/config/i386/avxintrin.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx-loadu2-m128-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-loadu2-m128-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-loadu2-m128d-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-loadu2-m128i-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-storeu2-m128-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-storeu2-m128-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-storeu2-m128d-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx-storeu2-m128i-2.c [new file with mode: 0644]

index 2de2e652357bcfb15e16a29d953e7fb60fc8c72c..121da52b33cb622e31bbb0caa561bfc8d50ddf4f 100644 (file)
@@ -1,3 +1,10 @@
+2019-08-05  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <kito.cheng@sifive.com>
 
        * config/riscv/riscv.c (riscv_promote_function_mode): New.
index 29115a11a0d3fe6cc770c853b8876ba3322e4f67..18c0711a8ad183295c9d6b11adafe6d80d8a5e0f 100644 (file)
@@ -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
index 8fe569ac17686681d244585783ac98471dc35c2f..e19f136370bf62a90843e0a6c795da9b68153d3c 100644 (file)
@@ -1,3 +1,19 @@
+2019-08-05  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <kito.cheng@sifive.com>
 
        * 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 (file)
index 0000000..d5b5ad2
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx" } */
+/* { dg-final { scan-assembler "\tvmovups\t" } } */
+/* { dg-final { scan-assembler "\tvinsertf128\t" } } */
+
+#include <immintrin.h>
+
+__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 (file)
index 0000000..b962c2c
--- /dev/null
@@ -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 (file)
index 0000000..3cdd497
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx" } */
+/* { dg-final { scan-assembler "\tvmovupd\t" } } */
+/* { dg-final { scan-assembler "\tvinsertf128\t" } } */
+
+#include <immintrin.h>
+
+__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 (file)
index 0000000..d342fdc
--- /dev/null
@@ -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 (file)
index 0000000..32d5444
--- /dev/null
@@ -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 <immintrin.h>
+
+__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 (file)
index 0000000..e090b98
--- /dev/null
@@ -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 (file)
index 0000000..cca79c5
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx" } */
+/* { dg-final { scan-assembler "\tvmovups\t" } } */
+/* { dg-final { scan-assembler "\tvextractf128\t" } } */
+
+#include <immintrin.h>
+
+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 (file)
index 0000000..81c823a
--- /dev/null
@@ -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 (file)
index 0000000..01cb223
--- /dev/null
@@ -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 <immintrin.h>
+
+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 (file)
index 0000000..37c23c2
--- /dev/null
@@ -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 (file)
index 0000000..bf2e72a
--- /dev/null
@@ -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 <immintrin.h>
+
+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 (file)
index 0000000..dd1825f
--- /dev/null
@@ -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 ();
+}