2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vptestmw-2.c
blob4378f2aa3878105e7ec6fd4eec13eecaa4849c17
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
5 #define AVX512BW
6 #include "avx512f-helper.h"
8 #define SIZE (AVX512F_LEN / 16)
9 #include "avx512f-mask-type.h"
11 void
12 CALC (MASK_TYPE *res, short *src1, short *src2)
14 int i;
15 *res = 0;
16 MASK_TYPE one = 1;
18 for (i = 0; i < SIZE; i++)
19 if (src1[i] & src2[i])
20 *res = *res | one << i;
23 void
24 TEST (void)
26 int i, sign = 1;
27 UNION_TYPE (AVX512F_LEN, i_w) src1, src2;
28 MASK_TYPE res_ref, res1, res2;
29 MASK_TYPE mask = MASK_VALUE;
31 for (i = 0; i < SIZE; i++)
33 src1.a[i] = i * i * sign;
34 src2.a[i] = i + 20;
35 sign = -sign;
38 res1 = INTRINSIC (_test_epi16_mask) (src1.x, src2.x);
39 res2 = INTRINSIC (_mask_test_epi16_mask) (mask, src1.x, src2.x);
41 CALC (&res_ref, src1.a, src2.a);
43 if (res1 != res_ref)
44 abort ();
46 res_ref &= mask;
48 if (res2 != res_ref)
49 abort ();