1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
4 
5 #define AVX512F
6 
7 #include "avx512f-helper.h"
8 
9 #define SIZE (AVX512F_LEN / 32)
10 #include "avx512f-mask-type.h"
11 
12 static void
CALC(int * r,int * s1,int * s2)13 CALC (int *r, int *s1, int *s2)
14 {
15   int i;
16   for (i = 0; i < SIZE; i++)
17     {
18       r[i] =
19 	s2[i] < 32 ? (s1[i] >> s2[i]) : (s1[i] > 0 ? 0 : 0xFFFFFFFF);
20     }
21 }
22 
23 void
TEST(void)24 TEST (void)
25 {
26   int i, sign;
27   UNION_TYPE (AVX512F_LEN, i_d) res1, res2, res3, src1, src2;
28   MASK_TYPE mask = MASK_VALUE;
29   int res_ref[SIZE];
30 
31   sign = -1;
32   for (i = 0; i < SIZE; i++)
33     {
34       src1.a[i] = 2 + sign * 7 * i % 291;
35       src2.a[i] = 1 + 17 * i % 71;
36       sign = sign * -1;
37     }
38 
39   for (i = 0; i < SIZE; i++)
40     res2.a[i] = DEFAULT_VALUE;
41 
42   res1.x = INTRINSIC (_srav_epi32) (src1.x, src2.x);
43   res2.x = INTRINSIC (_mask_srav_epi32) (res2.x, mask, src1.x, src2.x);
44   res3.x = INTRINSIC (_maskz_srav_epi32) (mask, src1.x, src2.x);
45 
46   CALC (res_ref, src1.a, src2.a);
47 
48   if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
49     abort ();
50 
51   MASK_MERGE (i_d) (res_ref, mask, SIZE);
52   if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
53     abort ();
54 
55   MASK_ZERO (i_d) (res_ref, mask, SIZE);
56   if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
57     abort ();
58 }
59