openmp: Add testcases for omp_max_vf
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / no-vfa-vect-depend-3.c
blob7a80d89da8d366ce4b1c9163777dd1257ab37c17
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-additional-options "--param vect-max-version-for-alias-checks=0" } */
4 #include <stdarg.h>
5 #include "tree-vect.h"
7 #define N 64
9 int ia[N + 1];
10 int ib[N + 1];
12 /* Vectorizable. Dependence distance -1. */
13 __attribute__((noinline)) void
14 f1 (void)
16 int i;
17 for (i = 0; i < N; i++)
19 ia[i + 1] = 1;
20 ib[i] = ia[i];
24 /* Not vectorizable due to data dependence: dependence distance 1. */
25 __attribute__((noinline)) void
26 f2 (void)
28 int i;
29 for (i = 0; i < N; i++)
31 ia[i] = 1;
32 ib[i] = ia[i + 1];
36 /* Not vectorizable due to data dependence: dependence distance 1. */
37 __attribute__((noinline)) void
38 f3 (void)
40 int i;
41 for (i = N - 1; i >= 0; i--)
43 ia[i + 1] = 1;
44 ib[i] = ia[i];
48 /* Vectorizable. Dependence distance -1. */
49 __attribute__((noinline)) void
50 f4 (void)
52 int i;
53 for (i = N - 1; i >= 0; i--)
55 ia[i] = 1;
56 ib[i] = ia[i + 1];
60 /* Vectorizable. Dependence distance -1. */
61 __attribute__((noinline)) void
62 f5 (void)
64 int i;
65 for (i = 0; i < N; i++)
67 ia[i + 1] = 1;
68 ia[i] = 2;
72 /* Not vectorizable due to data dependence: dependence distance 1. */
73 __attribute__((noinline)) void
74 f6 (void)
76 int i;
77 for (i = 0; i < N; i++)
79 ia[i] = 1;
80 ia[i + 1] = 2;
84 /* Not vectorizable due to data dependence: dependence distance 1. */
85 __attribute__((noinline)) void
86 f7 (void)
88 int i;
89 for (i = N - 1; i >= 0; i--)
91 ia[i + 1] = 1;
92 ia[i] = 2;
96 /* Vectorizable. Dependence distance -1. */
97 __attribute__((noinline)) void
98 f8 (void)
100 int i;
101 for (i = N - 1; i >= 0; i--)
103 ia[i] = 1;
104 ia[i + 1] = 2;
108 __attribute__ ((noinline)) int
109 main1 (void)
111 int i, j;
113 for (j = 0; j < 8; j++)
115 for (i = 0; i <= N; i++)
117 ia[i] = i + 3;
118 ib[i] = i + N + 3;
119 asm ("");
122 switch (j)
124 case 0: f1 (); break;
125 case 1: f2 (); break;
126 case 2: f3 (); break;
127 case 3: f4 (); break;
128 case 4: f5 (); break;
129 case 5: f6 (); break;
130 case 6: f7 (); break;
131 case 7: f8 (); break;
134 #pragma GCC novector
135 for (i = 0; i <= N; i++)
137 int ea = i + 3;
138 int eb = i + N + 3;
139 switch (j)
141 case 0:
142 if (i) ea = 1;
143 if (i == 0) eb = 3;
144 else if (i != N) eb = 1;
145 break;
146 case 1:
147 if (i != N) ea = 1;
148 if (i != N) eb = i + 4;
149 break;
150 case 2:
151 if (i) ea = 1;
152 if (i != N) eb = i + 3;
153 break;
154 case 3:
155 if (i != N) ea = 1;
156 if (i < N - 1) eb = 1;
157 else if (i == N - 1) eb = 67;
158 break;
159 case 4:
160 ea = 1 + (i != N);
161 break;
162 case 5:
163 ea = 2 - (i != N);
164 break;
165 case 6:
166 ea = 1 + (i == 0);
167 break;
168 case 7:
169 ea = 2 - (i == 0);
170 break;
172 if (ia[i] != ea || ib[i] != eb)
173 abort ();
177 return 0;
180 int main ()
182 check_vect ();
184 return main1 ();
187 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" {xfail { vect_no_align && { ! vect_hw_misalign } } } } } */
188 /* { dg-final { scan-tree-dump-times "dependence distance negative" 4 "vect" } } */