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