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 #define SIZE (AVX512F_LEN / 16)
9 #include "avx512f-mask-type.h"
10
11 void
CALC(short * src1,short * src2,short * dst)12 CALC (short *src1, short *src2, short *dst)
13 {
14 int i, t0;
15
16 for (i = 0; i < SIZE; i++)
17 {
18 t0 = (((int) src1[i] * (int) src2[i]) >> 14) + 1;
19 dst[i] = (short) (t0 >> 1);
20 }
21 }
22
23 void
TEST(void)24 TEST (void)
25 {
26 UNION_TYPE (AVX512F_LEN, i_w) src1, src2, dst1, dst2, dst3;
27 short dst_ref[SIZE];
28 MASK_TYPE mask = MASK_VALUE;
29 int i, sign = -1;
30
31 for (i = 0; i < SIZE; i++)
32 {
33 src1.a[i] = i % 2;
34 src2.a[i] = i * sign;
35 dst2.a[i] = DEFAULT_VALUE;
36 sign = -sign;
37 }
38
39 dst1.x = INTRINSIC (_mulhrs_epi16) (src1.x, src2.x);
40 dst2.x =
41 INTRINSIC (_mask_mulhrs_epi16) (dst2.x, mask, src1.x, src2.x);
42 dst3.x = INTRINSIC (_maskz_mulhrs_epi16) (mask, src1.x, src2.x);
43
44 CALC (src1.a, src2.a, dst_ref);
45
46 if (UNION_CHECK (AVX512F_LEN, i_w) (dst1, dst_ref))
47 abort ();
48
49 MASK_MERGE (i_w) (dst_ref, mask, SIZE);
50 if (UNION_CHECK (AVX512F_LEN, i_w) (dst2, dst_ref))
51 abort ();
52
53 MASK_ZERO (i_w) (dst_ref, mask, SIZE);
54 if (UNION_CHECK (AVX512F_LEN, i_w) (dst3, dst_ref))
55 abort ();
56 }
57