Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr29947-2.c
blob231cd5d272171913e69662003bcc94c3815bd520
1 /* PR libgomp/29947 */
2 /* { dg-options "-O2 -fopenmp" } */
3 /* { dg-do run } */
5 extern void abort (void);
7 int cnt;
9 void
10 test1 (long j1, long k1, long j2, long k2)
12 long i, e = 0, c = 0;
13 #pragma omp parallel reduction (+:e,c)
15 #pragma omp for schedule (static)
16 for (i = j1; i <= k1; ++i)
18 if (i < j2 || i > k2)
19 ++e;
20 ++c;
22 #pragma omp atomic
23 ++cnt;
25 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
26 abort ();
29 void
30 test2 (long j1, long k1, long j2, long k2)
32 long i, e = 0, c = 0;
33 #pragma omp parallel reduction (+:e,c)
35 #pragma omp for schedule (static)
36 for (i = k1; i >= j1; --i)
38 if (i < j2 || i > k2)
39 ++e;
40 ++c;
42 #pragma omp atomic
43 ++cnt;
45 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
46 abort ();
49 void
50 test3 (long j1, long k1, long j2, long k2)
52 long i, e = 0, c = 0;
53 #pragma omp parallel reduction (+:e,c)
55 #pragma omp for schedule (static, 1)
56 for (i = j1; i <= k1; ++i)
58 if (i < j2 || i > k2)
59 ++e;
60 ++c;
62 #pragma omp atomic
63 ++cnt;
65 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
66 abort ();
69 void
70 test4 (long j1, long k1, long j2, long k2)
72 long i, e = 0, c = 0;
73 #pragma omp parallel reduction (+:e,c)
75 #pragma omp for schedule (static, 1)
76 for (i = k1; i >= j1; --i)
78 if (i < j2 || i > k2)
79 ++e;
80 ++c;
82 #pragma omp atomic
83 ++cnt;
85 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
86 abort ();
89 void
90 test5 (long j1, long k1, long j2, long k2)
92 long i, e = 0, c = 0;
93 #pragma omp parallel reduction (+:e,c)
95 #pragma omp for schedule (static) ordered
96 for (i = j1; i <= k1; ++i)
98 if (i < j2 || i > k2)
99 ++e;
100 #pragma omp ordered
101 ++c;
103 #pragma omp atomic
104 ++cnt;
106 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
107 abort ();
110 void
111 test6 (long j1, long k1, long j2, long k2)
113 long i, e = 0, c = 0;
114 #pragma omp parallel reduction (+:e,c)
116 #pragma omp for schedule (static) ordered
117 for (i = k1; i >= j1; --i)
119 if (i < j2 || i > k2)
120 ++e;
121 #pragma omp ordered
122 ++c;
124 #pragma omp atomic
125 ++cnt;
127 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
128 abort ();
131 void
132 test7 (long j1, long k1, long j2, long k2)
134 long i, e = 0, c = 0;
135 #pragma omp parallel reduction (+:e,c)
137 #pragma omp for schedule (static, 1) ordered
138 for (i = j1; i <= k1; ++i)
140 if (i < j2 || i > k2)
141 ++e;
142 #pragma omp ordered
143 ++c;
145 #pragma omp atomic
146 ++cnt;
148 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
149 abort ();
152 void
153 test8 (long j1, long k1, long j2, long k2)
155 long i, e = 0, c = 0;
156 #pragma omp parallel reduction (+:e,c)
158 #pragma omp for schedule (static, 1) ordered
159 for (i = k1; i >= j1; --i)
161 if (i < j2 || i > k2)
162 ++e;
163 #pragma omp ordered
164 ++c;
166 #pragma omp atomic
167 ++cnt;
169 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
170 abort ();
173 void
174 test9 (long j1, long k1, long j2, long k2)
176 long i, e = 0, c = 0;
177 #pragma omp parallel for reduction (+:e,c) schedule (static)
178 for (i = j1; i <= k1; ++i)
180 if (i < j2 || i > k2)
181 ++e;
182 ++c;
184 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
185 abort ();
188 void
189 test10 (long j1, long k1, long j2, long k2)
191 long i, e = 0, c = 0;
192 #pragma omp parallel for reduction (+:e,c) schedule (static)
193 for (i = k1; i >= j1; --i)
195 if (i < j2 || i > k2)
196 ++e;
197 ++c;
199 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
200 abort ();
203 void
204 test11 (long j1, long k1, long j2, long k2)
206 long i, e = 0, c = 0;
207 #pragma omp parallel for reduction (+:e,c) schedule (static, 1)
208 for (i = j1; i <= k1; ++i)
210 if (i < j2 || i > k2)
211 ++e;
212 ++c;
214 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
215 abort ();
218 void
219 test12 (long j1, long k1, long j2, long k2)
221 long i, e = 0, c = 0;
222 #pragma omp parallel for reduction (+:e,c) schedule (static, 1)
223 for (i = k1; i >= j1; --i)
225 if (i < j2 || i > k2)
226 ++e;
227 ++c;
229 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
230 abort ();
233 void
234 test13 (long j1, long k1, long j2, long k2)
236 long i, e = 0, c = 0;
237 #pragma omp parallel for reduction (+:e,c) schedule (static) ordered
238 for (i = j1; i <= k1; ++i)
240 if (i < j2 || i > k2)
241 ++e;
242 #pragma omp ordered
243 ++c;
245 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
246 abort ();
249 void
250 test14 (long j1, long k1, long j2, long k2)
252 long i, e = 0, c = 0;
253 #pragma omp parallel for reduction (+:e,c) schedule (static) ordered
254 for (i = k1; i >= j1; --i)
256 if (i < j2 || i > k2)
257 ++e;
258 #pragma omp ordered
259 ++c;
261 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
262 abort ();
265 void
266 test15 (long j1, long k1, long j2, long k2)
268 long i, e = 0, c = 0;
269 #pragma omp parallel for reduction (+:e,c) schedule (static, 1) ordered
270 for (i = j1; i <= k1; ++i)
272 if (i < j2 || i > k2)
273 ++e;
274 #pragma omp ordered
275 ++c;
277 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
278 abort ();
281 void
282 test16 (long j1, long k1, long j2, long k2)
284 long i, e = 0, c = 0;
285 #pragma omp parallel for reduction (+:e,c) schedule (static, 1) ordered
286 for (i = k1; i >= j1; --i)
288 if (i < j2 || i > k2)
289 ++e;
290 #pragma omp ordered
291 ++c;
293 if (e || (c != j2 > k2 ? 0 : k2 - j2 + 1))
294 abort ();
298 __attribute__((noinline))
299 test (long j1, long k1, long j2, long k2)
301 test1 (j1, k1, j2, k2);
302 test2 (j1, k1, j2, k2);
303 test3 (j1, k1, j2, k2);
304 test4 (j1, k1, j2, k2);
305 test5 (j1, k1, j2, k2);
306 test6 (j1, k1, j2, k2);
307 test7 (j1, k1, j2, k2);
308 test8 (j1, k1, j2, k2);
309 test9 (j1, k1, j2, k2);
310 test10 (j1, k1, j2, k2);
311 test11 (j1, k1, j2, k2);
312 test12 (j1, k1, j2, k2);
313 test13 (j1, k1, j2, k2);
314 test14 (j1, k1, j2, k2);
315 test15 (j1, k1, j2, k2);
316 test16 (j1, k1, j2, k2);
317 return cnt;
321 main (void)
323 test (1, 5, 1, 5);
324 test (5, 5, 5, 5);
325 test (5, 4, 5, 4);
326 test (5, 1, 5, 1);
327 return 0;