Rebase.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vcvtpd2dq-2.c
blobcdaa182f31b5279ef197877c39f874b647f8b678
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 SRC_SIZE ((AVX512F_LEN) / 64)
10 #include "avx512f-mask-type.h"
11 #define DST_SIZE ((AVX512F_LEN_HALF) / 32)
13 static void
14 CALC (double *s, int *r)
16 int i;
18 for (i = 0; i < SRC_SIZE; i++)
20 r[i] = (s[i] >= 0) ? (int) (s[i] + 0.5)
21 : (int) (s[i] - 0.5);
25 void
26 TEST (void)
28 UNION_TYPE (AVX512F_LEN, d) s;
29 UNION_TYPE (AVX512F_LEN_HALF, i_d) res1, res2, res3;
30 MASK_TYPE mask = MASK_VALUE;
31 int res_ref[DST_SIZE] = { 0 };
32 int i, sign = 1;
34 for (i = 0; i < SRC_SIZE; i++)
36 s.a[i] = 123.456 * (i + 2000) * sign;
37 sign = -sign;
40 for (i = 0; i < DST_SIZE; i++)
41 res2.a[i] = DEFAULT_VALUE;
43 res1.x = INTRINSIC (_cvtpd_epi32) (s.x);
44 res2.x = INTRINSIC (_mask_cvtpd_epi32) (res2.x, mask, s.x);
45 res3.x = INTRINSIC (_maskz_cvtpd_epi32) (mask, s.x);
47 CALC (s.a, res_ref);
49 if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res1, res_ref))
50 abort ();
52 MASK_MERGE (i_d) (res_ref, mask, SRC_SIZE);
53 if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res2, res_ref))
54 abort ();
56 MASK_ZERO (i_d) (res_ref, mask, SRC_SIZE);
57 if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res3, res_ref))
58 abort ();