| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-mavx512f -O2" } */ |
| 3 |
/* { dg-require-effective-target avx512f } */ |
| 4 |
|
| 5 |
#include "avx512f-check.h" |
| 6 |
|
| 7 |
#define SCALE 2 |
| 8 |
|
| 9 |
static void |
| 10 |
compute_scatterdd (__mmask16 m16, int *idx, |
| 11 |
int *src, int scale, int *r) |
| 12 |
{ |
| 13 |
int i; |
| 14 |
|
| 15 |
for (i = 0; i < 16; i++) |
| 16 |
{ |
| 17 |
if (m16 & (1 << i)) |
| 18 |
*(int *) (((unsigned char *) r) + idx[i] * scale) = src[i]; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
static void |
| 23 |
avx512f_test (void) |
| 24 |
{ |
| 25 |
int i; |
| 26 |
union512i_d src, idx; |
| 27 |
int res[16] = { 0 }; |
| 28 |
int res_ref[16] = { 0 }; |
| 29 |
__mmask16 m16 = 0xBC5D; |
| 30 |
|
| 31 |
for (i = 0; i < 16; i++) |
| 32 |
{ |
| 33 |
src.a[i] = 1973 * (i + 1) * (i + 2); |
| 34 |
|
| 35 |
/* About to gather in reverse order, |
| 36 |
divide by 2 to demonstrate scale */ |
| 37 |
idx.a[i] = (64 - (i + 1) * 4) >> 1; |
| 38 |
} |
| 39 |
|
| 40 |
_mm512_mask_i32scatter_epi32 (res, m16, idx.x, src.x, SCALE); |
| 41 |
compute_scatterdd (m16, idx.a, src.a, SCALE, res_ref); |
| 42 |
|
| 43 |
if (checkVi (res, res_ref, 16)) |
| 44 |
abort (); |
| 45 |
|
| 46 |
_mm512_i32scatter_epi32 (res, idx.x, src.x, SCALE); |
| 47 |
compute_scatterdd (0xFFFF, idx.a, src.a, SCALE, res_ref); |
| 48 |
|
| 49 |
if (checkVi (res, res_ref, 16)) |
| 50 |
abort (); |
| 51 |
} |