Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpmulhuw-2.c
blob512940a2765502a245f0056820f36316f5000b15
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw -DAVX512BW" } */
3 /* { dg-require-effective-target avx512bw } */
5 #include "avx512f-helper.h"
7 #define SIZE (AVX512F_LEN / 16)
8 #include "avx512f-mask-type.h"
10 void
11 CALC (short *src1, short *src2, short *dst)
13 int i;
15 for (i = 0; i < SIZE; i++)
16 dst[i] = (src1[i] * src2[i]) >> 16;
19 void
20 TEST (void)
22 UNION_TYPE (AVX512F_LEN, i_w) src1, src2, dst1, dst2, dst3;
23 short dst_ref[SIZE];
24 MASK_TYPE mask = MASK_VALUE;
25 int i, sign = -1;
27 for (i = 0; i < SIZE; i++)
29 src1.a[i] = i % 2;
30 src2.a[i] = i * sign;
31 dst2.a[i] = DEFAULT_VALUE;
32 sign = -sign;
35 dst1.x = INTRINSIC (_mulhi_epu16) (src1.x, src2.x);
36 dst2.x =
37 INTRINSIC (_mask_mulhi_epu16) (dst2.x, mask, src1.x, src2.x);
38 dst3.x = INTRINSIC (_maskz_mulhi_epu16) (mask, src1.x, src2.x);
40 CALC (src1.a, src2.a, dst_ref);
42 if (UNION_CHECK (AVX512F_LEN, i_w) (dst1, dst_ref))
43 abort ();
45 MASK_MERGE (i_w) (dst_ref, mask, SIZE);
46 if (UNION_CHECK (AVX512F_LEN, i_w) (dst2, dst_ref))
47 abort ();
49 MASK_ZERO (i_w) (dst_ref, mask, SIZE);
50 if (UNION_CHECK (AVX512F_LEN, i_w) (dst3, dst_ref))
51 abort ();