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_i64gatherps256(float * src,float * s1,long long * s2,float * mask,int scale,float * r)9 compute_i64gatherps256 (float *src,
10 			float *s1,
11 			long long *s2, float *mask, int scale, float *r)
12 {
13   int i;
14 
15   for (i = 0; i < 4; ++i)
16     if ((((int *) mask)[i] >> 31) & 1)
17       r[i] = *(float *) (((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   int i;
26   union256i_q idx;
27   union128 res, src, mask;
28   float s1[4], res_ref[4] = { 0 };
29 
30   for (i = 0; i < 4; ++i)
31     {
32       /* Set some stuff */
33       s1[i] = 2.718281828459045 * (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       ((int *) mask.a)[i] = i % 2 ? 0 : -1;
40 
41       /* About to gather in reverse order,
42          divide by 2 to demonstrate scale */
43       idx.a[i] = (16 - (i + 1) * 4) >> 1;
44     }
45 
46   res.x = _mm256_mask_i64gather_ps (src.x, s1, idx.x, mask.x, 2);
47 
48   compute_i64gatherps256 (src.a, s1, idx.a, mask.a, 2, res_ref);
49 
50   if (check_union128 (res, res_ref) != 0)
51     abort ();
52 }
53