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
9 static void
compute_scatterqps(__mmask8 m8,long long * idx,float * src,int scale,float * r)10 compute_scatterqps (__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 *(float *) (((unsigned char *) r) + idx[i] * scale) = src[i];
19 }
20 }
21
22 static void
avx512f_test(void)23 avx512f_test (void)
24 {
25 int i;
26 union256 src;
27 union512i_q idx;
28 float res[8] = { 0.0 };
29 float res_ref[8] = { 0.0 };
30 __mmask8 m8 = 0xC5;
31
32 for (i = 0; i < 8; i++)
33 {
34 src.a[i] = 2.718281828459045 * (i + 1) * (i + 2);
35
36 /* About to gather in reverse order,
37 divide by 2 to demonstrate scale */
38 idx.a[i] = (32 - (i + 1) * 4) >> 1;
39 }
40
41 _mm512_mask_i64scatter_ps (res, m8, idx.x, src.x, SCALE);
42 compute_scatterqps (m8, idx.a, src.a, SCALE, res_ref);
43
44 if (checkVf (res, res_ref, 8))
45 abort ();
46
47 _mm512_i64scatter_ps (res, idx.x, src.x, SCALE);
48 compute_scatterqps (0xFF, idx.a, src.a, SCALE, res_ref);
49
50 if (checkVf (res, res_ref, 8))
51 abort ();
52 }
53