+2008-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgomp/35625
+ * iter.c (gomp_iter_guided_next_locked): If q > n, set end to ws->end.
+ (gomp_iter_guided_next): Likewise.
+ * testsuite/libgomp.c/pr35625.c: New test.
+
2008-03-16 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* aclocal.m4: Regenerate.
if (ws->next == ws->end)
return false;
- n = (ws->end - ws->next) / ws->incr;
+ start = ws->next;
+ n = (ws->end - start) / ws->incr;
q = (n + nthreads - 1) / nthreads;
if (q < ws->chunk_size)
q = ws->chunk_size;
- if (q > n)
- q = n;
-
- start = ws->next;
- end = start + q * ws->incr;
+ if (q <= n)
+ end = start + q * ws->incr;
+ else
+ end = ws->end;
ws->next = end;
*pstart = start;
if (start == end)
return false;
- n = (end - start) / ws->incr;
+ n = (end - start) / incr;
q = (n + nthreads - 1) / nthreads;
if (q < chunk_size)
q = chunk_size;
- if (q > n)
- q = n;
-
- nend = start + q * incr;
+ if (__builtin_expect (q <= n, 1))
+ nend = start + q * incr;
+ else
+ nend = end;
tmp = __sync_val_compare_and_swap (&ws->next, start, nend);
if (__builtin_expect (tmp == start, 1))
--- /dev/null
+/* PR libgomp/35625 */
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+int
+main (void)
+{
+#pragma omp parallel
+ {
+ #pragma omp for schedule (guided, 10)
+ for (int i = 0; i < 1826; i += 10)
+ ;
+ #pragma omp for schedule (guided, 10)
+ for (int i = 0; i > -1826; i -= 10)
+ ;
+ }
+ return 0;
+}