1 /* { dg-do run } */
2 /* { dg-options "-mavx2 -O2" } */
3 /* { dg-require-effective-target avx2 } */
4
5 #include "avx2-check.h"
6 #include <string.h>
7
8 #define NUM 10
9
10 static void
init_permps(float * src1,int * src2,int seed)11 init_permps (float *src1, int *src2, int seed)
12 {
13 int i, sign = 1;
14
15 for (i = 0; i < 8; i++)
16 {
17 src1[i] = (i + seed) * (i + seed) * sign;
18 src2[i] = (i + seed + 20) * sign;
19 sign = -sign;
20 }
21 }
22
23 static void
calc_permps(float * src1,int * src2,float * dst)24 calc_permps (float *src1, int *src2, float *dst)
25 {
26 int i;
27 unsigned temp;
28
29 memcpy (dst, src1, 32);
30 for (i = 0; i < 8; i++)
31 {
32 temp = src2[i];
33 dst[i] = src1[temp & 7];
34 }
35 }
36
37 static void
avx2_test(void)38 avx2_test (void)
39 {
40 union256 src1, dst;
41 union256i_d src2;
42 float dst_ref[8];
43 int i;
44
45 for (i = 0; i < NUM; i++)
46 {
47 init_permps (src1.a, src2.a, i);
48
49 dst.x = _mm256_permutevar8x32_ps (src1.x, src2.x);
50 calc_permps (src1.a, src2.a, dst_ref);
51
52 if (check_union256 (dst, dst_ref))
53 abort ();
54 }
55 }
56