PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-i64gatherps512-2.c
blob8ed0fcef4095f33e08f1c15f3ad08a12e097b350
1 /* { dg-do run } */
2 /* { dg-options "-mavx512f -O2" } */
3 /* { dg-require-effective-target avx512f } */
5 #include "avx512f-check.h"
7 #define SCALE 2
9 static void
10 compute_gatherqps (float *res, __mmask8 m8, long long *idx,
11 float *src, int scale, float *r)
13 int i;
15 for (i = 0; i < 8; i++)
17 if (m8 & (1 << i))
18 r[i] = *(float *) (((unsigned char *) src) + idx[i] * scale);
19 else
20 r[i] = res[i];
24 static void
25 avx512f_test (void)
27 int i;
28 union256 res;
29 union512i_q idx;
30 float src[8];
31 float res_ref[8];
32 __mmask8 m8 = 0xC5;
34 res.x = _mm256_setzero_ps();
36 for (i = 0; i < 8; i++)
38 src[i] = 2.718281828459045 * (i + 1) * (i + 2);
40 /* About to gather in reverse order,
41 divide by 2 to demonstrate scale */
42 idx.a[i] = (32 - (i + 1) * 4) >> 1;
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);
48 if (check_union256 (res, res_ref))
49 abort ();
51 res.x = _mm512_i64gather_ps (idx.x, src, SCALE);
52 compute_gatherqps (res.a, 0xFF, idx.a, src, SCALE, res_ref);
54 if (check_union256 (res, res_ref))
55 abort ();