2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512f-vexpandps-2.c
blob7b6a5404f6d9b248306026a115825ebd2239fb80
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 static void
13 CALC (float *s, float *r, MASK_TYPE mask)
15 int i, k;
17 for (i = 0, k = 0; i < SIZE; i++)
19 if (mask & (1 << i))
20 r[i] = s[k++];
24 void
25 TEST (void)
27 UNION_TYPE (AVX512F_LEN, ) s1, res2, res3, res4, res5;
28 MASK_TYPE mask = MASK_VALUE;
29 float s2[SIZE];
30 float res_ref1[SIZE];
31 float res_ref2[SIZE];
32 float res_ref3[SIZE];
33 int i, sign = 1;
35 for (i = 0; i < SIZE; i++)
37 s1.a[i] = 123.456 * (i + 200) * sign;
38 s2[i] = 789.012 * (i + 300) * sign;
39 res2.a[i] = DEFAULT_VALUE;
40 res4.a[i] = DEFAULT_VALUE;
41 sign = -sign;
44 res2.x = INTRINSIC (_mask_expand_ps) (res2.x, mask, s1.x);
45 res3.x = INTRINSIC (_maskz_expand_ps) (mask, s1.x);
46 res4.x = INTRINSIC (_mask_expandloadu_ps) (res4.x, mask, s2);
47 res5.x = INTRINSIC (_maskz_expandloadu_ps) (mask, s2);
49 CALC (s1.a, res_ref1, MASK_ALL_ONES);
50 CALC (s1.a, res_ref2, mask);
51 CALC (s2, res_ref3, mask);
53 MASK_MERGE () (res_ref2, mask, SIZE);
54 if (UNION_CHECK (AVX512F_LEN, ) (res2, res_ref2))
55 abort ();
57 MASK_ZERO () (res_ref2, mask, SIZE);
58 if (UNION_CHECK (AVX512F_LEN, ) (res3, res_ref2))
59 abort ();
61 MASK_MERGE () (res_ref3, mask, SIZE);
62 if (UNION_CHECK (AVX512F_LEN, ) (res4, res_ref3))
63 abort ();
65 MASK_ZERO () (res_ref3, mask, SIZE);
66 if (UNION_CHECK (AVX512F_LEN, ) (res5, res_ref3))
67 abort ();