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
9static void
10compute_gatherqps (float *res, __mmask8 m8, long long *idx,
11		   float *src, int scale, float *r)
12{
13  int i;
14
15  for (i = 0; i < 8; i++)
16    {
17      if (m8 & (1 << i))
18	r[i] = *(float *) (((unsigned char *) src) + idx[i] * scale);
19      else
20	r[i] = res[i];
21    }
22}
23
24static void
25avx512f_test (void)
26{
27  int i;
28  union256 res;
29  union512i_q idx;
30  float src[8];
31  float res_ref[8];
32  __mmask8 m8 = 0xC5;
33
34  res.x = _mm256_setzero_ps();
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] = (32 - (i + 1) * 4) >> 1;
43    }
44
45  res.x = _mm512_mask_i64gather_ps (res.x, m8, idx.x, src, SCALE);
46  compute_gatherqps (res.a, m8, idx.a, src, SCALE, res_ref);
47
48  if (check_union256 (res, res_ref))
49    abort ();
50
51  res.x = _mm512_i64gather_ps (idx.x, src, SCALE);
52  compute_gatherqps (res.a, 0xFF, idx.a, src, SCALE, res_ref);
53
54  if (check_union256 (res, res_ref))
55    abort ();
56}
57