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
13static void
14CALC (double *s, int *r)
15{
16  int i;
17
18  for (i = 0; i < SRC_SIZE; i++)
19    {
20      r[i] = (int) s[i];
21    }
22}
23
24void
25TEST (void)
26{
27  UNION_TYPE (AVX512F_LEN, d) s;
28  UNION_TYPE (AVX512F_LEN_HALF, i_d) res1, res2, res3;
29  MASK_TYPE mask = MASK_VALUE;
30  int res_ref[DST_SIZE] = { 0 };
31  int i, sign = 1;
32
33  for (i = 0; i < SRC_SIZE; i++)
34    {
35      s.a[i] = 123.456 * (i + 2000) * sign;
36      sign = -sign;
37    }
38
39  for (i = 0; i < DST_SIZE; i++)
40    res2.a[i] = DEFAULT_VALUE;
41
42  res1.x = INTRINSIC (_cvttpd_epi32) (s.x);
43  res2.x = INTRINSIC (_mask_cvttpd_epi32) (res2.x, mask, s.x);
44  res3.x = INTRINSIC (_maskz_cvttpd_epi32) (mask, s.x);
45
46  CALC (s.a, res_ref);
47
48  if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res1, res_ref))
49    abort ();
50
51  MASK_MERGE (i_d) (res_ref, mask, SRC_SIZE);
52  if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res2, res_ref))
53    abort ();
54
55  MASK_ZERO (i_d) (res_ref, mask, SRC_SIZE);
56  if (UNION_CHECK (AVX512F_LEN_HALF, i_d) (res3, res_ref))
57    abort ();
58}
59