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