Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-pr114375.c

raw
1 /* { dg-additional-options "-mavx2" { target avx2_runtime } } */
2
3 #include "tree-vect.h"
4
5 int a[512];
6 int b[512];
7 int c[512];
8
9 void __attribute__((noipa))
10 foo(int * __restrict p)
11 {
12 for (int i = 0; i < 64; ++i)
13 {
14 int tem = 2, tem2 = 2;
15 if (a[4*i + 1])
16 tem = p[4*i];
17 if (a[4*i])
18 tem2 = p[4*i + 2];
19 b[2*i] = tem2;
20 b[2*i+1] = tem;
21 if (a[4*i + 2])
22 tem = p[4*i + 1];
23 if (a[4*i + 3])
24 tem2 = p[4*i + 3];
25 c[2*i] = tem2;
26 c[2*i+1] = tem;
27 }
28 }
29 int main()
30 {
31 check_vect ();
32
33 #pragma GCC novector
34 for (int i = 0; i < 512; ++i)
35 a[i] = (i >> 1) & 1;
36
37 foo (a);
38
39 if (c[0] != 1 || c[1] != 0 || c[2] != 1 || c[3] != 0
40 || b[0] != 2 || b[1] != 2 || b[2] != 2 || b[3] != 2)
41 abort ();
42
43 return 0;
44 }
45
46 /* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target avx2 } } } */