Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpmovswb-2.c
blob88d1ee101dc44e4d1c6c59e3c1e39b268eaff22b
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw -DAVX512BW" } */
3 /* { dg-require-effective-target avx512bw } */
5 #include "avx512f-helper.h"
7 #define SIZE (AVX512F_LEN / 16)
8 #define SIZE_HALF (AVX512F_LEN_HALF / 8)
9 #include "avx512f-mask-type.h"
10 #include <limits.h>
12 CALC (char *r, short *s)
14 int i;
15 for (i = 0; i < SIZE_HALF; i++)
17 if (s[i] < CHAR_MIN)
18 r[i] = CHAR_MIN;
19 else if (s[i] > CHAR_MAX)
20 r[i] = CHAR_MAX;
21 else
22 r[i] = s[i];
23 r[i] = (i < SIZE) ? r[i] : 0;
27 void
28 TEST (void)
30 int i, sign;
31 UNION_TYPE (AVX512F_LEN_HALF, i_b) res1, res2, res3;
32 UNION_TYPE (AVX512F_LEN, i_w) src;
33 MASK_TYPE mask = MASK_VALUE;
34 char res_ref[32];
36 sign = -1;
37 for (i = 0; i < SIZE; i++)
39 src.a[i] = 1 + 34 * i * sign;
40 sign = sign * -1;
41 res2.a[i] = DEFAULT_VALUE;
44 res1.x = INTRINSIC (_cvtsepi16_epi8) (src.x);
45 res2.x = INTRINSIC (_mask_cvtsepi16_epi8) (res2.x, mask, src.x);
46 res3.x = INTRINSIC (_maskz_cvtsepi16_epi8) (mask, src.x);
48 CALC (res_ref, src.a);
50 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res1, res_ref))
51 abort ();
53 MASK_MERGE (i_b) (res_ref, mask, SIZE);
54 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res2, res_ref))
55 abort ();
57 MASK_ZERO (i_b) (res_ref, mask, SIZE);
58 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res3, res_ref))
59 abort ();