PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-i64gatherd512-2.c
blobdff818db4eac5d98b9da731e6374373e7c0a00f6
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_gatherqd (int *res, __mmask8 m8, long long *idx,
11 int *src, int scale, int *r)
13 int i;
15 for (i = 0; i < 8; i++)
17 if (m8 & (1 << i))
18 r[i] = *(int *) (((unsigned char *) src) + idx[i] * scale);
19 else
20 r[i] = res[i];
24 static void
25 avx512f_test (void)
27 int i;
28 union256i_d res;
29 union512i_q idx;
30 int src[8];
31 int res_ref[8];
32 __mmask8 m8 = 0xC5;
34 for (i = 0; i < 8; i++)
36 src[i] = 1973 * (i + 1) * (i + 2);
38 /* About to gather in reverse order,
39 divide by 2 to demonstrate scale */
40 idx.a[i] = (32 - (i + 1) * 4) >> 1;
43 res.x = _mm512_mask_i64gather_epi32 (res.x, m8, idx.x, src, SCALE);
44 compute_gatherqd (res.a, m8, idx.a, src, SCALE, res_ref);
46 if (check_union256i_d (res, res_ref))
47 abort ();
49 res.x = _mm512_i64gather_epi32 (idx.x, src, SCALE);
50 compute_gatherqd (res.a, 0xFF, idx.a, src, SCALE, res_ref);
52 if (check_union256i_d (res, res_ref))
53 abort ();