| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O3 -mvsx -Wno-psabi" } */ |
| 3 |
/* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */ |
| 4 |
/* { dg-require-effective-target p8vector_hw } */ |
| 5 |
|
| 6 |
#ifndef CHECK_H |
| 7 |
#define CHECK_H "sse2-check.h" |
| 8 |
#endif |
| 9 |
|
| 10 |
#include CHECK_H |
| 11 |
|
| 12 |
#ifndef TEST |
| 13 |
#define TEST sse2_test_psadbw_1 |
| 14 |
#endif |
| 15 |
|
| 16 |
#include <emmintrin.h> |
| 17 |
|
| 18 |
static __m128i |
| 19 |
__attribute__((noinline, unused)) |
| 20 |
test (__m128i s1, __m128i s2) |
| 21 |
{ |
| 22 |
return _mm_sad_epu8 (s1, s2); |
| 23 |
} |
| 24 |
|
| 25 |
static void |
| 26 |
TEST (void) |
| 27 |
{ |
| 28 |
union128i_ub s1, s2; |
| 29 |
union128i_w u; |
| 30 |
short e[8] = { 0 }; |
| 31 |
unsigned char tmp[16]; |
| 32 |
int i; |
| 33 |
|
| 34 |
s1.x = _mm_set_epi8 (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16); |
| 35 |
s2.x = _mm_set_epi8 (16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1); |
| 36 |
u.x = test (s1.x, s2.x); |
| 37 |
|
| 38 |
for (i = 0; i < 16; i++) |
| 39 |
tmp [i] = __builtin_abs (s1.a[i] - s2.a[i]); |
| 40 |
|
| 41 |
for (i = 0; i < 8; i++) |
| 42 |
e[0] += tmp[i]; |
| 43 |
|
| 44 |
for (i = 8; i < 16; i++) |
| 45 |
e[4] += tmp[i]; |
| 46 |
|
| 47 |
|
| 48 |
if (check_union128i_w (u, e)) |
| 49 |
{ |
| 50 |
#if DEBUG |
| 51 |
printf ("sse2_test_psadbw_1; check_union128i_w failed\n"); |
| 52 |
printf ("\tadds\t([%x,%x,%x,%x, %x,%x,%x,%x," |
| 53 |
" %x,%x,%x,%x, %x,%x,%x,%x],\n", |
| 54 |
s1.a[0], s1.a[1], s1.a[2], s1.a[3], s1.a[4], s1.a[5], s1.a[6], |
| 55 |
s1.a[7], s1.a[8], s1.a[9], s1.a[10], s1.a[11], s1.a[12], |
| 56 |
s1.a[13], s1.a[14], s1.a[15]); |
| 57 |
printf ("\t\t [%x,%x,%x,%x, %x,%x,%x,%x, %x,%x,%x,%x, %x,%x,%x,%x])\n", |
| 58 |
s2.a[0], s2.a[1], s2.a[2], s2.a[3], s2.a[4], s2.a[5], s2.a[6], |
| 59 |
s2.a[7], s2.a[8], s2.a[9], s2.a[10], s2.a[11], s2.a[12], |
| 60 |
s2.a[13], s2.a[14], s2.a[15]); |
| 61 |
printf ("\t ->\t [%x,%x,%x,%x, %x,%x,%x,%x]\n", u.a[0], u.a[1], u.a[2], |
| 62 |
u.a[3], u.a[4], u.a[5], u.a[6], u.a[7]); |
| 63 |
printf ("\texpect\t [%x,%x,%x,%x, %x,%x,%x,%x]\n", e[0], e[1], e[2], |
| 64 |
e[3], e[4], e[5], e[6], e[7]); |
| 65 |
#endif |
| 66 |
abort (); |
| 67 |
} |
| 68 |
} |