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_gatherqq(long long * res,__mmask8 m8,long long * idx,long long * src,int scale,long long * r)10 compute_gatherqq (long long *res, __mmask8 m8, long long *idx,
11 long long *src, int scale, long long *r)
12 {
13 int i;
14
15 for (i = 0; i < 8; i++)
16 {
17 if (m8 & (1 << i))
18 r[i] = *(long long *)
19 (((unsigned char *) src) + idx[i] * scale);
20 else
21 r[i] = res[i];
22 }
23 }
24
25 static void
avx512f_test(void)26 avx512f_test (void)
27 {
28 int i;
29 union512i_q idx, res;
30 long long src[8];
31 long long res_ref[8];
32 __mmask8 m8 = 0xC5;
33
34 for (i = 0; i < 8; i++)
35 {
36 src[i] = 1983 * (i + 1) * (i + 2);
37
38 /* About to gather in reverse order,
39 divide by 2 to demonstrate scale */
40 idx.a[i] = (64 - (i + 1) * 8) >> 1;
41 }
42
43 res.x = _mm512_mask_i64gather_epi64 (res.x, m8, idx.x, src, SCALE);
44 compute_gatherqq (res.a, m8, idx.a, src, SCALE, res_ref);
45
46 if (check_union512i_q (res, res_ref))
47 abort ();
48
49 res.x = _mm512_i64gather_epi64 (idx.x, src, SCALE);
50 compute_gatherqq (res.a, 0xFF, idx.a, src, SCALE, res_ref);
51
52 if (check_union512i_q (res, res_ref))
53 abort ();
54 }
55