| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target ssse3 } */ |
| 3 |
/* { dg-options "-O2 -fno-strict-aliasing -mssse3" } */ |
| 4 |
|
| 5 |
#ifndef CHECK_H |
| 6 |
#define CHECK_H "ssse3-check.h" |
| 7 |
#endif |
| 8 |
|
| 9 |
#ifndef TEST |
| 10 |
#define TEST ssse3_test |
| 11 |
#endif |
| 12 |
|
| 13 |
#include CHECK_H |
| 14 |
|
| 15 |
#include "ssse3-vals.h" |
| 16 |
#include <tmmintrin.h> |
| 17 |
|
| 18 |
/* Test the 64-bit form */ |
| 19 |
static void |
| 20 |
ssse3_test_pabsb (int *i1, int *r) |
| 21 |
{ |
| 22 |
__m64 t1 = *(__m64 *) i1; |
| 23 |
*(__m64 *) r = _mm_abs_pi8 (t1); |
| 24 |
_mm_empty (); |
| 25 |
} |
| 26 |
|
| 27 |
/* Test the 128-bit form */ |
| 28 |
static void |
| 29 |
ssse3_test_pabsb128 (int *i1, int *r) |
| 30 |
{ |
| 31 |
/* Assumes incoming pointers are 16-byte aligned */ |
| 32 |
__m128i t1 = *(__m128i *) i1; |
| 33 |
*(__m128i *) r = _mm_abs_epi8 (t1); |
| 34 |
} |
| 35 |
|
| 36 |
/* Routine to manually compute the results */ |
| 37 |
static void |
| 38 |
compute_correct_result (int *i1, int *r) |
| 39 |
{ |
| 40 |
char *b1 = (char *) i1; |
| 41 |
char *bout = (char *) r; |
| 42 |
int i; |
| 43 |
|
| 44 |
for (i = 0; i < 16; i++) |
| 45 |
if (b1[i] < 0) |
| 46 |
bout[i] = -b1[i]; |
| 47 |
else |
| 48 |
bout[i] = b1[i]; |
| 49 |
} |
| 50 |
|
| 51 |
static void |
| 52 |
TEST (void) |
| 53 |
{ |
| 54 |
int i; |
| 55 |
int r [4] __attribute__ ((aligned(16))); |
| 56 |
int ck [4]; |
| 57 |
int fail = 0; |
| 58 |
|
| 59 |
for (i = 0; i < 256; i += 4) |
| 60 |
{ |
| 61 |
/* Manually compute the result */ |
| 62 |
compute_correct_result(&vals[i + 0], ck); |
| 63 |
|
| 64 |
/* Run the 64-bit tests */ |
| 65 |
ssse3_test_pabsb (&vals[i + 0], &r[0]); |
| 66 |
ssse3_test_pabsb (&vals[i + 2], &r[2]); |
| 67 |
fail += chk_128 (ck, r); |
| 68 |
|
| 69 |
/* Run the 128-bit tests */ |
| 70 |
ssse3_test_pabsb128 (&vals[i + 0], r); |
| 71 |
fail += chk_128 (ck, r); |
| 72 |
} |
| 73 |
|
| 74 |
if (fail != 0) |
| 75 |
abort (); |
| 76 |
} |