Rebase.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpmovsdb-2.c
blob116c8b69e717d6095700edb1d392990efd26829f
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
5 #define AVX512F
7 #include "avx512f-helper.h"
9 #define SIZE (AVX512F_LEN / 32)
10 #include "avx512f-mask-type.h"
11 #include <limits.h>
13 static void
14 CALC (char *r, int *s)
16 int i;
17 for (i = 0; i < 16; 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 (128, i_b) res1, res2, res3;
34 char res4[16];
35 UNION_TYPE (AVX512F_LEN, i_d) src;
36 MASK_TYPE mask = MASK_VALUE;
37 char res_ref[16];
39 sign = -1;
40 for (i = 0; i < SIZE; i++)
42 src.a[i] = 1 + 34 * i * sign;
43 sign = sign * -1;
44 res2.a[i] = DEFAULT_VALUE;
45 res4[i] = DEFAULT_VALUE;
48 res1.x = INTRINSIC (_cvtsepi32_epi8) (src.x);
49 res2.x = INTRINSIC (_mask_cvtsepi32_epi8) (res2.x, mask, src.x);
50 res3.x = INTRINSIC (_maskz_cvtsepi32_epi8) (mask, src.x);
51 INTRINSIC (_mask_cvtsepi32_storeu_epi8) (res4, mask, src.x);
53 CALC (res_ref, src.a);
55 if (UNION_CHECK (128, i_b) (res1, res_ref))
56 abort ();
58 MASK_MERGE (i_b) (res_ref, mask, SIZE);
59 if (UNION_CHECK (128, i_b) (res2, res_ref))
60 abort ();
62 if (checkVc (res4, res_ref, 16))
63 abort ();
65 MASK_ZERO (i_b) (res_ref, mask, SIZE);
66 if (UNION_CHECK (128, i_b) (res3, res_ref))
67 abort ();