2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpmovswb-2.c
blob69e25a27c4da4e9f3dd7c6b994f946076804424f
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 #define SIZE_HALF (AVX512F_LEN_HALF / 8)
10 #include "avx512f-mask-type.h"
11 #include <limits.h>
13 void
14 CALC (char *r, short *s)
16 int i;
17 for (i = 0; i < SIZE_HALF; i++)
19 if (s[i] < CHAR_MIN)
20 r[i] = CHAR_MIN;
21 else if (s[i] > CHAR_MAX)
22 r[i] = CHAR_MAX;
23 else
24 r[i] = s[i];
25 r[i] = (i < SIZE) ? r[i] : 0;
29 void
30 TEST (void)
32 int i, sign;
33 UNION_TYPE (AVX512F_LEN_HALF, i_b) res1, res2, res3;
34 UNION_TYPE (AVX512F_LEN, i_w) src;
35 MASK_TYPE mask = MASK_VALUE;
36 char res_ref[32];
38 sign = -1;
39 for (i = 0; i < SIZE; i++)
41 src.a[i] = 1 + 34 * i * sign;
42 sign = sign * -1;
43 res2.a[i] = DEFAULT_VALUE;
46 res1.x = INTRINSIC (_cvtsepi16_epi8) (src.x);
47 res2.x = INTRINSIC (_mask_cvtsepi16_epi8) (res2.x, mask, src.x);
48 res3.x = INTRINSIC (_maskz_cvtsepi16_epi8) (mask, src.x);
50 CALC (res_ref, src.a);
52 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res1, res_ref))
53 abort ();
55 MASK_MERGE (i_b) (res_ref, mask, SIZE);
56 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res2, res_ref))
57 abort ();
59 MASK_ZERO (i_b) (res_ref, mask, SIZE);
60 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res3, res_ref))
61 abort ();