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
compute_gatherqd(int * res,__mmask8 m8,long long * idx,int * src,int scale,int * r)10 compute_gatherqd (int *res, __mmask8 m8, long long *idx,
11 int *src, int scale, int *r)
12 {
13 int i;
14
15 for (i = 0; i < 8; i++)
16 {
17 if (m8 & (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 union256i_d res;
29 union512i_q idx;
30 int src[8];
31 int res_ref[8];
32 __mmask8 m8 = 0xC5;
33
34 for (i = 0; i < 8; i++)
35 {
36 src[i] = 1973 * (i + 1) * (i + 2);
37
38 /* About to gather in reverse order,
39 divide by 2 to demonstrate scale */
40 idx.a[i] = (32 - (i + 1) * 4) >> 1;
41 }
42
43 res.x = _mm512_mask_i64gather_epi32 (res.x, m8, idx.x, src, SCALE);
44 compute_gatherqd (res.a, m8, idx.a, src, SCALE, res_ref);
45
46 if (check_union256i_d (res, res_ref))
47 abort ();
48
49 res.x = _mm512_i64gather_epi32 (idx.x, src, SCALE);
50 compute_gatherqd (res.a, 0xFF, idx.a, src, SCALE, res_ref);
51
52 if (check_union256i_d (res, res_ref))
53 abort ();
54 }
55