1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f -mavx512vnni" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-require-effective-target avx512vnni } */
5 
6 #define AVX512F
7 
8 #define AVX512VNNI
9 #include "avx512f-helper.h"
10 
11 #define SIZE (AVX512F_LEN / 16)
12 #define SIZE_RES (AVX512F_LEN / 32)
13 
14 #include "avx512f-mask-type.h"
15 
16 static void
CALC(int * r,int * dst,short * s1,short * s2)17 CALC (int *r, int *dst, short *s1, short *s2)
18 {
19   short tempres[SIZE];
20   for (int i = 0; i < SIZE; i++) {
21     tempres[i] = ((int)(s1[i]) * (int)(s2[i]));
22   }
23   for (int i = 0; i < SIZE_RES; i++) {
24     long long test = (long long)dst[i] + tempres[i*2] + tempres[i*2 + 1];
25     r[i] = test;
26   }
27 }
28 
29 void
TEST(void)30 TEST (void)
31 {
32   int i;
33   UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3;
34   UNION_TYPE (AVX512F_LEN, i_w) src1, src2;
35   MASK_TYPE mask = MASK_VALUE;
36   int res_ref[SIZE_RES];
37   int res_ref2[SIZE_RES];
38 
39   for (i = 0; i < SIZE; i++)
40     {
41       src1.a[i] = 1 + i;
42       src2.a[i] = 2 + 2*i;
43     }
44 
45   for (i = 0; i < SIZE_RES; i++)
46     {
47       res1.a[i] = 0x7fffffff;
48       res2.a[i] = DEFAULT_VALUE;
49       res3.a[i] = DEFAULT_VALUE;
50     }
51 
52   CALC (res_ref, res1.a, src1.a, src2.a);
53   CALC (res_ref2, res2.a, src1.a, src2.a);
54 
55   res1.x = INTRINSIC (_dpwssd_epi32) (res1.x, src1.x, src2.x);
56   res2.x = INTRINSIC (_mask_dpwssd_epi32) (res2.x, mask, src1.x, src2.x);
57   res3.x = INTRINSIC (_maskz_dpwssd_epi32) (mask, res3.x, src1.x, src2.x);
58 
59   if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
60     abort ();
61 
62   MASK_MERGE (i_d) (res_ref2, mask, SIZE_RES);
63   if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref2))
64     abort ();
65 
66   MASK_ZERO (i_d) (res_ref2, mask, SIZE_RES);
67   if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref2))
68     abort ();
69 }
70