PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vpermilps-2.c
blobfc1ded7b4b60c469a207794550d6e4d61d267e7a
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 233
14 #endif
16 #undef mask_v
17 #define mask_v(pos) ((CTRL & (0x3 << (pos))) >> (pos))
19 static void
20 CALC (float *s1, int *s2, float *r)
22 int i;
24 for (i = 0; i < SIZE; i++)
25 r[i] = s1[(4 * (i / 4)) + (s2[i] & 0x03)];
28 void
29 TEST (void)
31 UNION_TYPE (AVX512F_LEN,) s1, res1, res2, res3;
32 UNION_TYPE (AVX512F_LEN, i_d) s2;
33 MASK_TYPE mask = MASK_VALUE;
34 float res_ref[SIZE];
35 int i;
37 for (i = 0; i < SIZE; i++)
39 s1.a[i] = i + 10.;
40 s2.a[i] = mask_v (i);
41 res2.a[i] = DEFAULT_VALUE;
44 res1.x = INTRINSIC (_permutevar_ps) (s1.x, s2.x);
45 res2.x = INTRINSIC (_mask_permutevar_ps) (res2.x, mask, s1.x, s2.x);
46 res3.x = INTRINSIC (_maskz_permutevar_ps) (mask, s1.x, s2.x);
48 CALC (s1.a, s2.a, res_ref);
50 if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref))
51 abort ();
53 MASK_MERGE ()(res_ref, mask, SIZE);
54 if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
55 abort ();
57 MASK_ZERO ()(res_ref, mask, SIZE);
58 if (UNION_CHECK (AVX512F_LEN,) (res3, res_ref))
59 abort ();