Rebase.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpmovsqw-2.c
blobbc1619a8308b44052d82e2f19abb2894db205ba9
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 / 64)
10 #include "avx512f-mask-type.h"
11 #include <limits.h>
13 void static
14 CALC (short *r, long long *s)
16 int i;
17 for (i = 0; i < 8; i++)
19 if (s[i] < SHRT_MIN)
20 r[i] = SHRT_MIN;
21 else if (s[i] > SHRT_MAX)
22 r[i] = SHRT_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_w) res1, res2, res3;
34 short res4[8];
35 UNION_TYPE (AVX512F_LEN, i_q) src;
36 MASK_TYPE mask = MASK_VALUE;
37 short res_ref[8];
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 (_cvtsepi64_epi16) (src.x);
49 res2.x = INTRINSIC (_mask_cvtsepi64_epi16) (res2.x, mask, src.x);
50 res3.x = INTRINSIC (_maskz_cvtsepi64_epi16) (mask, src.x);
51 INTRINSIC (_mask_cvtsepi64_storeu_epi16) (res4, mask, src.x);
53 CALC (res_ref, src.a);
55 if (UNION_CHECK (128, i_w) (res1, res_ref))
56 abort ();
58 MASK_MERGE (i_w) (res_ref, mask, SIZE);
59 if (UNION_CHECK (128, i_w) (res2, res_ref))
60 abort ();
62 if (checkVs (res4, res_ref, 8))
63 abort ();
65 MASK_ZERO (i_w) (res_ref, mask, SIZE);
66 if (UNION_CHECK (128, i_w) (res3, res_ref))
67 abort ();