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 #define MASK 0xf1
11
12 static void
init_permq(unsigned long long * src1,int seed)13 init_permq (unsigned long long *src1, int seed)
14 {
15 int i, sign = 1;
16
17 for (i = 0; i < 4; i++)
18 {
19 src1[i] = (i + seed) * (i + seed) * sign;
20 sign = -sign;
21 }
22 }
23
24 static void
calc_permq(unsigned long long * src1,unsigned int mask,unsigned long long * dst)25 calc_permq (unsigned long long *src1, unsigned int mask,
26 unsigned long long *dst)
27 {
28 int i, temp;
29
30 for (i = 0; i < 4; i++)
31 {
32 temp = (mask >> (2 * i)) & 3;
33 dst[i] = src1[temp];
34 }
35 }
36
37 static void
avx2_test(void)38 avx2_test (void)
39 {
40 union256i_q src1, dst;
41 unsigned long long dst_ref[4];
42 int i;
43
44 for (i = 0; i < NUM; i++)
45 {
46 init_permq (src1.a, i);
47
48 dst.x = _mm256_permute4x64_epi64 (src1.x, MASK);
49 calc_permq (src1.a, MASK, dst_ref);
50
51 if (check_union256i_q (dst, dst_ref))
52 abort ();
53 }
54 }
55