| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target avx2 } */ |
| 3 |
/* { dg-options "-O2 -mavx2" } */ |
| 4 |
|
| 5 |
#include <string.h> |
| 6 |
#include "avx2-check.h" |
| 7 |
|
| 8 |
static void |
| 9 |
compute_pshufb256 (char *s1, char *s2, char *r) |
| 10 |
{ |
| 11 |
int i; |
| 12 |
char select; |
| 13 |
|
| 14 |
for (i = 0; i < 16; i++) |
| 15 |
{ |
| 16 |
select = s2[i]; |
| 17 |
if (select & 0x80) |
| 18 |
r[i] = 0; |
| 19 |
else |
| 20 |
r[i] = s1[select & 0xf]; |
| 21 |
|
| 22 |
select = s2[i + 16]; |
| 23 |
if (select & 0x80) |
| 24 |
r[i + 16] = 0; |
| 25 |
else |
| 26 |
r[i + 16] = s1[16 + (select & 0xf)]; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
void static |
| 31 |
avx2_test (void) |
| 32 |
{ |
| 33 |
union256i_b s1, s2, res; |
| 34 |
char res_ref[32]; |
| 35 |
int i, j; |
| 36 |
int fail = 0; |
| 37 |
|
| 38 |
for (i = 0; i < 10; i++) |
| 39 |
{ |
| 40 |
for (j = 0; j < 32; j++) |
| 41 |
{ |
| 42 |
s1.a[j] = j * i; |
| 43 |
s2.a[j] = j + 20; |
| 44 |
} |
| 45 |
|
| 46 |
res.x = _mm256_shuffle_epi8 (s1.x, s2.x); |
| 47 |
compute_pshufb256 (s1.a, s2.a, res_ref); |
| 48 |
|
| 49 |
fail += check_union256i_b (res, res_ref); |
| 50 |
} |
| 51 |
|
| 52 |
if (fail != 0) |
| 53 |
abort (); |
| 54 |
} |