2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpermd-2.c
blobdbd4544c39e93f6fba2a01b43f1b9e5fb135cb45
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
5 #define AVX512F
7 #include "avx512f-helper.h"
10 #define SIZE (AVX512F_LEN / 32)
11 #include "avx512f-mask-type.h"
13 static void
14 CALC (int *mask, int *src1, int *dst)
16 int i;
18 for (i = 0; i < SIZE; i++)
20 #if AVX512F_LEN == 512
21 dst[i] = src1[mask[i] & 15];
22 #else
23 dst[i] = src1[mask[i] & 7];
24 #endif
28 void
29 TEST (void)
31 UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3, src1, src2;
32 MASK_TYPE mask = MASK_VALUE;
33 int res_ref[SIZE];
34 int i, sign = 1;
36 for (i = 0; i < SIZE; i++)
38 src1.a[i] = (i + 10) * (i + 10) * sign;
39 src2.a[i] = (i + 30);
40 sign = -sign;
41 res3.a[i] = DEFAULT_VALUE;
44 #if AVX512F_LEN == 512
45 res1.x = INTRINSIC (_permutexvar_epi32) (src1.x, src2.x);
46 #endif
47 res2.x = INTRINSIC (_maskz_permutexvar_epi32) (mask, src1.x, src2.x);
48 res3.x = INTRINSIC (_mask_permutexvar_epi32) (res3.x, mask, src1.x, src2.x);
50 CALC (src1.a, src2.a, res_ref);
52 #if AVX512F_LEN == 512
53 if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
54 abort ();
55 #endif
57 MASK_ZERO (i_d) (res_ref, mask, SIZE);
58 if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
59 abort ();
61 MASK_MERGE (i_d) (res_ref, mask, SIZE);
62 if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
63 abort ();