1/* { dg-do run } */
2/* { dg-options "-O2 -mavx512ifma" } */
3/* { dg-require-effective-target avx512ifma } */
4
5#define AVX512IFMA
6
7#include "avx512f-helper.h"
8
9#define SIZE (AVX512F_LEN / 64)
10#include "avx512f-mask-type.h"
11
12void
13CALC (long long *r, long long *s1, long long *s2, long long *s3)
14{
15  int i;
16  long long a, b;
17
18  for (i = 0; i < SIZE; i++)
19    {
20      /* Simulate higher 52 bits out of 104 bit,
21	 by shifting opernads with 0 in lower 26 bits.  */
22      a = s2[i] >> 26;
23      b = s3[i] >> 26;
24      r[i] = a * b + s1[i];
25    }
26}
27
28void
29TEST (void)
30{
31  UNION_TYPE (AVX512F_LEN, i_q) src1, src2, dst1, dst2, dst3;
32  long long dst_ref[SIZE];
33  int i;
34  MASK_TYPE mask = MASK_VALUE;
35
36  for (i = 0; i < SIZE; i++)
37    {
38      src1.a[i] = 15 + 3467 * i;
39      src2.a[i] = 9217 + i;
40      src1.a[i] = src1.a[i] << 26;
41      src1.a[i] = src1.a[i] << 26;
42      src1.a[i] &= ((1LL << 52) - 1);
43      src2.a[i] &= ((1LL << 52) - 1);
44      dst1.a[i] = DEFAULT_VALUE;
45      dst2.a[i] = DEFAULT_VALUE;
46      dst3.a[i] = DEFAULT_VALUE;
47    }
48
49  CALC (dst_ref, dst1.a, src1.a, src2.a);
50  dst1.x = INTRINSIC (_madd52hi_epu64) (dst1.x, src1.x, src2.x);
51  dst2.x = INTRINSIC (_mask_madd52hi_epu64) (dst2.x, mask, src1.x, src2.x);
52  dst3.x = INTRINSIC (_maskz_madd52hi_epu64) (mask, dst3.x, src1.x, src2.x);
53
54  if (UNION_CHECK (AVX512F_LEN, i_q) (dst1, dst_ref))
55    abort ();
56
57  MASK_MERGE (i_q) (dst_ref, mask, SIZE);
58  if (UNION_CHECK (AVX512F_LEN, i_q) (dst2, dst_ref))
59    abort ();
60
61  MASK_ZERO (i_q) (dst_ref, mask, SIZE);
62  if (UNION_CHECK (AVX512F_LEN, i_q) (dst3, dst_ref))
63    abort ();
64}
65