Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpermilpsi-2.c
blob986dbd17aa284bb484a2643cb8ea0d1cdcbfa73a
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f" } */
3 /* { dg-require-effective-target avx512f } */
5 #define AVX512F
7 #include "avx512f-helper.h"
9 #define SIZE (AVX512F_LEN / 32)
10 #include "avx512f-mask-type.h"
12 #ifndef CTRL
13 #define CTRL 129
14 #endif
16 #ifndef SELECT4_DEFINED
17 #define SELECT4_DEFINED
18 static int
19 select4 (int i, unsigned ctrl)
21 int res;
22 switch (i % 4)
24 case 0:
25 res = (CTRL & 0x03);
26 break;
27 case 1:
28 res = ((CTRL & 0x0c) >> 2);
29 break;
30 case 2:
31 res = ((CTRL & 0x30) >> 4);
32 break;
33 case 3:
34 res = ((CTRL & 0xc0) >> 6);
35 break;
37 return res;
39 #endif
41 static void
42 CALC (float *s, float *r)
44 int i;
46 for (i = 0; i < SIZE; i++)
48 r[i] = s[(4 * (i / 4)) + select4 (i, CTRL)];
52 void
53 TEST (void)
55 UNION_TYPE (AVX512F_LEN,) s1, res1, res2, res3;
56 MASK_TYPE mask = MASK_VALUE;
57 float res_ref[SIZE];
58 int i;
60 for (i = 0; i < SIZE; i++)
62 s1.a[i] = i + 10.;
63 res2.a[i] = DEFAULT_VALUE;
66 res1.x = INTRINSIC (_permute_ps) (s1.x, CTRL);
67 res2.x = INTRINSIC (_mask_permute_ps) (res2.x, mask, s1.x, CTRL);
68 res3.x = INTRINSIC (_maskz_permute_ps) (mask, s1.x, CTRL);
70 CALC (s1.a, res_ref);
72 if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref))
73 abort ();
75 MASK_MERGE ()(res_ref, mask, SIZE);
76 if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
77 abort ();
79 MASK_ZERO ()(res_ref, mask, SIZE);
80 if (UNION_CHECK (AVX512F_LEN,) (res3, res_ref))
81 abort ();