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_i32gatherd256(int * s1,int * s2,int scale,int * r)9 compute_i32gatherd256 (int *s1, int *s2, int scale, int *r)
10 {
11   int i;
12 
13   for (i = 0; i < 8; ++i)
14     r[i] = *(int *) (((unsigned char *) s1) + s2[i] * scale);
15 }
16 
17 void static
avx2_test(void)18 avx2_test (void)
19 {
20   int i;
21   union256i_d idx;
22   union256i_d res;
23   int s1[8], res_ref[8] = { 0 };
24 
25   for (i = 0; i < 8; ++i)
26     {
27       /* Set some stuff */
28       s1[i] = 1973 * (i + 1) * (i + 2);
29 
30       /* About to gather in reverse order,
31          divide by 2 to demonstrate scale */
32       idx.a[i] = (32 - (i + 1) * 4) >> 1;
33     }
34 
35   res.x = _mm256_i32gather_epi32 (s1, idx.x, 2);
36 
37   compute_i32gatherd256 (s1, idx.a, 2, res_ref);
38 
39   if (check_union256i_d (res, res_ref) != 0)
40     abort ();
41 }
42