Debian Codegraph @

gcc/testsuite/gcc.dg/vect/section-anchors-vect-69.c

raw
1 /* { dg-require-effective-target section_anchors } */
2 /* { dg-additional-options "--param vect-max-peeling-for-alignment=0" } */
3
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #if VECTOR_BITS > 128
8 #define NINTS (VECTOR_BITS / 32)
9 #else
10 #define NINTS 4
11 #endif
12
13 #define N (NINTS * 8)
14
15 struct s{
16 int m;
17 int n[N][N][N];
18 };
19
20 struct s2{
21 int m;
22 int n[N-1][N-1][N-1];
23 };
24
25 struct test1{
26 struct s a; /* array a.n is unaligned */
27 int pad[NINTS - 2];
28 struct s e; /* array e.n is aligned */
29 };
30
31 struct test2{
32 struct s2 a;
33 int b;
34 int c;
35 struct s2 e;
36 };
37
38
39 struct test1 tmp1[4];
40 struct test2 tmp2[4];
41
42 int main1 ()
43 {
44 int i,j;
45
46 /* 1. unaligned */
47 for (i = 0; i < N; i++)
48 {
49 tmp1[2].a.n[1][2][i] = 5;
50 }
51
52 /* check results: */
53 #pragma GCC novector
54 for (i = 0; i <N; i++)
55 {
56 if (tmp1[2].a.n[1][2][i] != 5)
57 abort ();
58 }
59
60 /* 2. aligned */
61 for (i = NINTS - 1; i < N - 1; i++)
62 {
63 tmp1[2].a.n[1][2][i] = 6;
64 }
65
66 /* check results: */
67 #pragma GCC novector
68 for (i = NINTS - 1; i < N - 1; i++)
69 {
70 if (tmp1[2].a.n[1][2][i] != 6)
71 abort ();
72 }
73
74 /* 3. aligned */
75 for (i = 0; i < N; i++)
76 {
77 for (j = 0; j < N; j++)
78 {
79 tmp1[2].e.n[1][i][j] = 8;
80 }
81 }
82
83 /* check results: */
84 for (i = 0; i < N; i++)
85 {
86 #pragma GCC novector
87 for (j = 0; j < N; j++)
88 {
89 if (tmp1[2].e.n[1][i][j] != 8)
90 abort ();
91 }
92 }
93
94 /* 4. unaligned */
95 for (i = 0; i < N - NINTS; i++)
96 {
97 for (j = 0; j < N - NINTS; j++)
98 {
99 tmp2[2].e.n[1][i][j] = 8;
100 }
101 }
102
103 /* check results: */
104 for (i = 0; i < N - NINTS; i++)
105 {
106 #pragma GCC novector
107 for (j = 0; j < N - NINTS; j++)
108 {
109 if (tmp2[2].e.n[1][i][j] != 8)
110 abort ();
111 }
112 }
113
114 return 0;
115 }
116
117 int main (void)
118 {
119 check_vect ();
120
121 return main1 ();
122 }
123
124 /* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_int } } } */
125 /* Alignment forced using versioning until the pass that increases alignment
126 is extended to handle structs. */
127 /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 4 "vect" { target {vect_int && {! vector_alignment_reachable} } } } } */