1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4 
5 #define AVX512F
6 
7 #include "avx512f-helper.h"
8 
9 #define SRC_SIZE ((AVX512F_LEN) / 64)
10 #include "avx512f-mask-type.h"
11 #define DST_SIZE ((AVX512F_LEN_HALF) / 32)
12 
13 static void
CALC(double * s,int * r)14 CALC (double *s, int *r)
15 {
16   int i;
17 
18   for (i = 0; i < SRC_SIZE; i++)
19     {
20       r[i] = (s[i] >= 0) ? (int) (s[i] + 0.5)
21 			 : (int) (s[i] - 0.5);
22     }
23 }
24 
25 void
TEST(void)26 TEST (void)
27 {
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;
33 
34   for (i = 0; i < SRC_SIZE; i++)
35     {
36       s.a[i] = 123.456 * (i + 2000) * sign;
37       sign = -sign;
38     }
39 
40   for (i = 0; i < DST_SIZE; i++)
41     res2.a[i] = DEFAULT_VALUE;
42 
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);
46 
47   CALC (s.a, res_ref);
48 
49   if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res1, res_ref))
50     abort ();
51 
52   MASK_MERGE (i_d) (res_ref, mask, SRC_SIZE);
53   if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res2, res_ref))
54     abort ();
55 
56   MASK_ZERO (i_d) (res_ref, mask, SRC_SIZE);
57   if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res3, res_ref))
58     abort ();
59 }
60