1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
4 
5 #define AVX512BW
6 #include "avx512f-helper.h"
7 
8 #include <math.h>
9 #include <limits.h>
10 #include <float.h>
11 #define SIZE (AVX512F_LEN / 32)
12 #include "avx512f-mask-type.h"
13 
14 void
CALC(short * i1,short * i2,int * r)15 CALC (short *i1, short *i2, int *r)
16 {
17   int i;
18 
19   for (i = 0; i < SIZE; i++)
20     r[i] = ((int) i1[2 * i] * (int) i2[2 * i] +
21 	    (int) i1[2 * i + 1] * (int) i2[2 * i + 1]);
22 }
23 
24 void
TEST(void)25 TEST (void)
26 {
27   UNION_TYPE (AVX512F_LEN, i_w) s1, s2;
28   UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3;
29   int res_ref[SIZE];
30   MASK_TYPE mask = MASK_VALUE;
31   int i;
32 
33   for (i = 0; i < SIZE * 2; i++)
34     {
35       s1.a[i] = i * 17 + i;
36       s2.a[i] = i * -17 + i * 2;
37     }
38 
39   for (i = 0; i < SIZE; i++)
40     {
41       res2.a[i] = DEFAULT_VALUE;
42     }
43 
44   res1.x = INTRINSIC (_madd_epi16) (s1.x, s2.x);
45   res2.x = INTRINSIC (_mask_madd_epi16) (res2.x, mask, s1.x, s2.x);
46   res3.x = INTRINSIC (_maskz_madd_epi16) (mask, s1.x, s2.x);
47 
48   CALC(s1.a, s2.a, res_ref);
49 
50   if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
51     abort ();
52 
53   MASK_MERGE (i_d) (res_ref, mask, SIZE);
54   if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
55     abort ();
56 
57   MASK_ZERO (i_d) (res_ref, mask, SIZE);
58   if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
59     abort ();
60 }
61