2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpunpckhbw-2.c
blob586699ec140b8aeb2b2a19ac11ff4e33522bbce2
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 / 8)
9 #include "avx512f-mask-type.h"
11 void
12 CALC (char *r, char *s1, char *s2)
14 int i;
15 for (i = 0; i < SIZE/16; i++)
17 r[16 * i] = s1[16 * i + 8];
18 r[16 * i + 1] = s2[16 * i + 8];
19 r[16 * i + 2] = s1[16 * i + 9];
20 r[16 * i + 3] = s2[16 * i + 9];
21 r[16 * i + 4] = s1[16 * i + 10];
22 r[16 * i + 5] = s2[16 * i + 10];
23 r[16 * i + 6] = s1[16 * i + 11];
24 r[16 * i + 7] = s2[16 * i + 11];
25 r[16 * i + 8] = s1[16 * i + 12];
26 r[16 * i + 9] = s2[16 * i + 12];
27 r[16 * i + 10] = s1[16 * i + 13];
28 r[16 * i + 11] = s2[16 * i + 13];
29 r[16 * i + 12] = s1[16 * i + 14];
30 r[16 * i + 13] = s2[16 * i + 14];
31 r[16 * i + 14] = s1[16 * i + 15];
32 r[16 * i + 15] = s2[16 * i + 15];
36 void
37 TEST (void)
39 int i, sign;
40 UNION_TYPE (AVX512F_LEN, i_b) res1, res2, res3, src1, src2;
41 MASK_TYPE mask = MASK_VALUE;
42 char res_ref[SIZE];
44 sign = -1;
45 for (i = 0; i < SIZE; i++)
47 src1.a[i] = 34 * i * sign;
48 src1.a[i] = 179 * i;
49 sign = sign * -1;
51 for (i = 0; i < SIZE; i++)
52 res2.a[i] = DEFAULT_VALUE;
54 res1.x = INTRINSIC (_unpackhi_epi8) (src1.x, src2.x);
55 res2.x = INTRINSIC (_mask_unpackhi_epi8) (res2.x, mask, src1.x, src2.x);
56 res3.x = INTRINSIC (_maskz_unpackhi_epi8) (mask, src1.x, src2.x);
58 CALC (res_ref, src1.a, src2.a);
60 if (UNION_CHECK (AVX512F_LEN, i_b) (res1, res_ref))
61 abort ();
63 MASK_MERGE (i_b) (res_ref, mask, SIZE);
64 if (UNION_CHECK (AVX512F_LEN, i_b) (res2, res_ref))
65 abort ();
67 MASK_ZERO (i_b) (res_ref, mask, SIZE);
68 if (UNION_CHECK (AVX512F_LEN, i_b) (res3, res_ref))
69 abort ();