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