Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx512bw-vpsrlw-2.c

raw
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
12 CALC (unsigned short *r, unsigned short *s1, unsigned short *s2)
13 {
14 int i;
15 unsigned short count = s2[0];
16 for (i = 0; i < SIZE; i++)
17 {
18 r[i] = count < 16 ? (s1[i] >> count) : 0;
19 }
20 }
21
22 void
23 TEST (void)
24 {
25 int i;
26 UNION_TYPE (AVX512F_LEN, i_w) res1, res2, res3, src1;
27 UNION_TYPE (128, i_w) src2;
28 MASK_TYPE mask = MASK_VALUE;
29 unsigned short res_ref[SIZE];
30
31 for (i = 0; i < SIZE; i++)
32 {
33 src1.a[i] = 2 + 7 * i % 291;
34 }
35
36 for (i = 0; i < 128 / 16; i++)
37 {
38 src2.a[i] = 0;
39 }
40
41 src2.a[0] = 1;
42 src2.a[1] = 0;
43 for (i = 0; i < SIZE; i++)
44 res2.a[i] = DEFAULT_VALUE;
45
46 res1.x = INTRINSIC (_srl_epi16) (src1.x, src2.x);
47 res2.x = INTRINSIC (_mask_srl_epi16) (res2.x, mask, src1.x, src2.x);
48 res3.x = INTRINSIC (_maskz_srl_epi16) (mask, src1.x, src2.x);
49
50 CALC (res_ref, src1.a, src2.a);
51
52 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
53 abort ();
54
55 MASK_MERGE (i_w) (res_ref, mask, SIZE);
56 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
57 abort ();
58
59 MASK_ZERO (i_w) (res_ref, mask, SIZE);
60 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
61 abort ();
62
63 src2.a[0] = 17;
64 for (i = 0; i < SIZE; i++)
65 res2.a[i] = DEFAULT_VALUE;
66
67 res1.x = INTRINSIC (_srl_epi16) (src1.x, src2.x);
68 res2.x = INTRINSIC (_mask_srl_epi16) (res2.x, mask, src1.x, src2.x);
69 res3.x = INTRINSIC (_maskz_srl_epi16) (mask, src1.x, src2.x);
70
71 CALC (res_ref, src1.a, src2.a);
72
73 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
74 abort ();
75
76 MASK_MERGE (i_w) (res_ref, mask, SIZE);
77 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
78 abort ();
79
80 MASK_ZERO (i_w) (res_ref, mask, SIZE);
81 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
82 abort ();
83 }