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
This commit is contained in:
Jakub Jelinek 2019-08-05 10:00:30 +02:00 committed by Jakub Jelinek
parent 860edc4662
commit 96d5c6dcf6
15 changed files with 242 additions and 0 deletions

View 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.

View 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

View 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.

View File

@ -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);
}

View File

@ -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 ();
}

View File

@ -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);
}

View File

@ -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 ();
}

View File

@ -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);
}

View File

@ -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 ();
}

View File

@ -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);
}

View File

@ -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 ();
}

View File

@ -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);
}

View File

@ -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 ();
}

View File

@ -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);
}

View File

@ -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 ();
}