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