1 /* { dg-do run } */
2 /* { dg-require-effective-target avx2 } */
3 /* { dg-options "-O2 -mavx2" } */
4
5 #include <string.h>
6 #include "avx2-check.h"
7
8 static void
compute_psrlw256(short * s1,long long int * s2,short * r)9 compute_psrlw256 (short *s1, long long int *s2, short *r)
10 {
11 int i;
12 int count = s2[0];
13
14 memset (r, 0, 32);
15
16 if (count < 16)
17 for (i = 0; i < 16; ++i)
18 r[i] = s1[i] >> count;
19 }
20
21 void static
avx2_test(void)22 avx2_test (void)
23 {
24 union256i_w s1, res;
25 union128i_q s2;
26 short res_ref[16];
27 int i, j;
28 int fail = 0;
29
30 for (i = 0; i < 10; i++)
31 {
32 for (j = 0; j < 16; j++)
33 s1.a[j] = j * i;
34
35 s2.a[0] = i;
36
37 res.x = _mm256_srl_epi16 (s1.x, s2.x);
38
39 compute_psrlw256 (s1.a, s2.a, res_ref);
40
41 fail += check_union256i_w (res, res_ref);
42
43 if (fail)
44 {
45 for (j = 0; j < 16; ++j)
46 printf ("%d <->%d\n", res.a[j], res_ref[j]);
47 abort ();
48 }
49 }
50
51 if (fail != 0)
52 abort ();
53 }
54