1 /* { dg-do run } */
2 /* { dg-require-effective-target avx2 } */
3 /* { dg-options "-O2 -mavx2" } */
4 
5 #include <string.h>
6 #include "avx2-check.h"
7 
8 static void
compute_i32gatherpd256(long long * src,long long * s1,int * s2,long long * mask,int scale,long long * r)9 compute_i32gatherpd256 (long long *src,
10 			long long *s1,
11 			int *s2, long long *mask, int scale, long long *r)
12 {
13   long long i;
14 
15   for (i = 0; i < 4; ++i)
16     if ((mask[i] >> 63) & 1)
17       r[i] = *(long long *) (((unsigned char *) s1) + s2[i] * scale);
18     else
19       r[i] = src[i];
20 }
21 
22 void static
avx2_test(void)23 avx2_test (void)
24 {
25   long long i;
26   union128i_d idx;
27   union256i_q res, src, mask;
28   long long s1[4], res_ref[4] = { 0 };
29 
30   for (i = 0; i < 4; ++i)
31     {
32       /* Set some stuff */
33       s1[i] = 1983 * (i + 1) * (i + 2);
34 
35       /* Set src as something different from s1 */
36       src.a[i] = -s1[i];
37 
38       /* Mask out evens */
39       mask.a[i] = i % 2 ? 0 : -1;
40 
41       /* About to gather in reverse order, divide by 2
42          to demonstrate scale */
43       idx.a[i] = (16 - (i + 1) * 8) >> 1;
44     }
45 
46   res.x = _mm256_mask_i32gather_epi64 (src.x,
47 				       (long long int *) s1,
48 				       idx.x, mask.x, 2);
49 
50   compute_i32gatherpd256 (src.a, s1, idx.a, mask.a, 2, res_ref);
51 
52   if (check_union256i_q (res, res_ref) != 0)
53     abort ();
54 }
55