| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mvsx -Wno-psabi" } */ |
| 3 |
/* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ |
| 4 |
/* { dg-require-effective-target p8vector_hw } */ |
| 5 |
|
| 6 |
#define NO_WARN_X86_INTRINSICS 1 |
| 7 |
#ifndef CHECK_H |
| 8 |
#define CHECK_H "sse4_1-check.h" |
| 9 |
#endif |
| 10 |
|
| 11 |
#ifndef TEST |
| 12 |
#define TEST sse4_1_test |
| 13 |
#endif |
| 14 |
|
| 15 |
#include CHECK_H |
| 16 |
|
| 17 |
#include <smmintrin.h> |
| 18 |
#include <string.h> |
| 19 |
|
| 20 |
#define NUM 20 |
| 21 |
|
| 22 |
#ifndef MASK |
| 23 |
#define MASK 0x0f |
| 24 |
#endif |
| 25 |
|
| 26 |
static void |
| 27 |
init_pblendw (short *src1, short *src2) |
| 28 |
{ |
| 29 |
int i, sign = 1; |
| 30 |
|
| 31 |
for (i = 0; i < NUM * 8; i++) |
| 32 |
{ |
| 33 |
src1[i] = i * i * sign; |
| 34 |
src2[i] = (i + 20) * sign; |
| 35 |
sign = -sign; |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
static int |
| 40 |
check_pblendw (__m128i *dst, short *src1, short *src2) |
| 41 |
{ |
| 42 |
short tmp[8]; |
| 43 |
int j; |
| 44 |
|
| 45 |
memcpy (&tmp[0], src1, sizeof (tmp)); |
| 46 |
for (j = 0; j < 8; j++) |
| 47 |
if ((MASK & (1 << j))) |
| 48 |
tmp[j] = src2[j]; |
| 49 |
|
| 50 |
return memcmp (dst, &tmp[0], sizeof (tmp)); |
| 51 |
} |
| 52 |
|
| 53 |
static void |
| 54 |
TEST (void) |
| 55 |
{ |
| 56 |
__m128i x, y; |
| 57 |
union |
| 58 |
{ |
| 59 |
__m128i x[NUM]; |
| 60 |
short s[NUM * 8]; |
| 61 |
} dst, src1, src2; |
| 62 |
union |
| 63 |
{ |
| 64 |
__m128i x; |
| 65 |
short s[8]; |
| 66 |
} src3; |
| 67 |
int i; |
| 68 |
|
| 69 |
init_pblendw (src1.s, src2.s); |
| 70 |
|
| 71 |
/* Check pblendw imm8, m128, xmm */ |
| 72 |
for (i = 0; i < NUM; i++) |
| 73 |
{ |
| 74 |
dst.x[i] = _mm_blend_epi16 (src1.x[i], src2.x[i], MASK); |
| 75 |
if (check_pblendw (&dst.x[i], &src1.s[i * 8], &src2.s[i * 8])) |
| 76 |
abort (); |
| 77 |
} |
| 78 |
|
| 79 |
/* Check pblendw imm8, xmm, xmm */ |
| 80 |
src3.x = _mm_setzero_si128 (); |
| 81 |
|
| 82 |
x = _mm_blend_epi16 (dst.x[2], src3.x, MASK); |
| 83 |
y = _mm_blend_epi16 (src3.x, dst.x[2], MASK); |
| 84 |
|
| 85 |
if (check_pblendw (&x, &dst.s[16], &src3.s[0])) |
| 86 |
abort (); |
| 87 |
|
| 88 |
if (check_pblendw (&y, &src3.s[0], &dst.s[16])) |
| 89 |
abort (); |
| 90 |
} |