| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-mavx2 -O2" } */ |
| 3 |
/* { dg-require-effective-target avx2 } */ |
| 4 |
|
| 5 |
#include "avx2-check.h" |
| 6 |
|
| 7 |
static void |
| 8 |
compute_pmaxsd256 (int *s1, int *s2, int *r) |
| 9 |
{ |
| 10 |
int i; |
| 11 |
|
| 12 |
for (i = 0; i < 8; i++) |
| 13 |
r[i] = s1[i] > s2[i] ? s1[i] : s2[i]; |
| 14 |
} |
| 15 |
|
| 16 |
static void |
| 17 |
avx2_test (void) |
| 18 |
{ |
| 19 |
union256i_d s1, s2, res; |
| 20 |
int res_ref[8]; |
| 21 |
int i, j, sign = 1; |
| 22 |
int fail = 0; |
| 23 |
|
| 24 |
for (i = 0; i < 10; i++) |
| 25 |
{ |
| 26 |
for (j = 0; j < 8; j++) |
| 27 |
{ |
| 28 |
s1.a[j] = j * i * sign; |
| 29 |
s2.a[j] = (i + 2000) * sign; |
| 30 |
sign = -sign; |
| 31 |
} |
| 32 |
|
| 33 |
res.x = _mm256_max_epi32 (s1.x, s2.x); |
| 34 |
|
| 35 |
compute_pmaxsd256 (s1.a, s2.a, res_ref); |
| 36 |
|
| 37 |
fail += check_union256i_d (res, res_ref); |
| 38 |
} |
| 39 |
|
| 40 |
if (fail != 0) |
| 41 |
abort (); |
| 42 |
} |