1 /* { dg-do run } */
2 /* { dg-options "-mavx2 -O2" } */
3 /* { dg-require-effective-target avx2 } */
4 
5 #include "avx2-check.h"
6 
7 static void
compute_pmulhuw256(unsigned short * s1,unsigned short * s2,unsigned short * r)8 compute_pmulhuw256 (unsigned short *s1, unsigned short *s2, unsigned short *r)
9 {
10   int i;
11 
12   for (i = 0; i < 16; i++)
13     r[i] = (s1[i] * s2[i]) >> 16;
14 }
15 
16 static void
avx2_test(void)17 avx2_test (void)
18 {
19   union256i_w s1, s2, res;
20   unsigned short res_ref[16];
21   int i, j;
22   int fail = 0;
23 
24   for (i = 0; i < 10; i++)
25     {
26       for (j = 0; j < 16; j++)
27 	{
28 	  s1.a[j] = i * j;
29 	  s2.a[j] = j + 20;
30 	}
31 
32       res.x = _mm256_mulhi_epu16 (s1.x, s2.x);
33 
34       compute_pmulhuw256 (s1.a, s2.a, res_ref);
35 
36       fail += check_union256i_w (res, res_ref);
37     }
38 
39   if (fail != 0)
40     abort ();
41 }
42