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 #include "math.h"
12
13 static void
CALC(int * dst,int * src1,int * ind,int * src2)14 CALC (int *dst, int *src1, int *ind, int *src2)
15 {
16 int i;
17
18 for (i = 0; i < SIZE; i++)
19 {
20 unsigned long long offset = ind[i] & (SIZE - 1);
21 unsigned long long cond = ind[i] & SIZE;
22
23 dst[i] = cond ? src2[offset] : src1[offset];
24 }
25 }
26
27 void
TEST(void)28 TEST (void)
29 {
30 int i;
31 UNION_TYPE (AVX512F_LEN, i_d) s1, s2, res, ind;
32 int res_ref[SIZE];
33
34 MASK_TYPE mask = MASK_VALUE;
35
36 for (i = 0; i < SIZE; i++)
37 {
38 ind.a[i] = DEFAULT_VALUE;
39 s1.a[i] = 34 * i + 1;
40 s2.a[i] = 34 * i;
41
42 res.a[i] = DEFAULT_VALUE;
43 }
44
45 CALC (res_ref, s1.a, ind.a, s2.a);
46
47 res.x =
48 INTRINSIC (_mask2_permutex2var_epi32) (s1.x, ind.x, mask, s2.x);
49
50 MASK_MERGE (i_d) (res_ref, mask, SIZE);
51 if (UNION_CHECK (AVX512F_LEN, i_d) (res, res_ref))
52 abort ();
53 }
54