2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-i32gatherd512-2.c
blobd89ef048d82eb8243b1f2b7b163ba6987922827a
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_gatherdd (int *res, __mmask16 m16, int *idx,
11 int *src, int scale, int *r)
13 int i;
15 for (i = 0; i < 16; i++)
17 if (m16 & (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 union512i_d idx, res;
29 int src[16];
30 int res_ref[16];
31 __mmask16 m16 = 0xBC5D;
33 for (i = 0; i < 16; i++)
35 src[i] = 1973 * (i + 1) * (i + 2);
37 /* About to gather in reverse order,
38 divide by 2 to demonstrate scale */
39 idx.a[i] = (64 - (i + 1) * 4) >> 1;
42 res.x = _mm512_mask_i32gather_epi32 (res.x, m16, idx.x, src, SCALE);
43 compute_gatherdd (res.a, m16, idx.a, src, SCALE, res_ref);
45 if (check_union512i_d (res, res_ref))
46 abort ();
48 res.x = _mm512_i32gather_epi32 (idx.x, src, SCALE);
49 compute_gatherdd (res.a, 0xFFFF, idx.a, src, SCALE, res_ref);
51 if (check_union512i_d (res, res_ref))
52 abort ();