From 22568cc62cabbea1eec20ef65e1da9b0caaa6f02 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 4 Dec 2006 11:26:00 +0100 Subject: re PR middle-end/29947 (OpenMP parallel for fails for reversed loop range) PR libgomp/29947 * omp-low.c (expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Do all arithmetics in signed rather than unsigned type. * loop.c (gomp_loop_init): Make parameters signed. Set ws->end to start if there shouldn't be any loop iterations. (gomp_loop_ordered_static_start): Remove start == end test. * testsuite/libgomp.c/pr29947-1.c: New test. * testsuite/libgomp.c/pr29947-2.c: New test. From-SVN: r119485 --- libgomp/loop.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'libgomp/loop.c') diff --git a/libgomp/loop.c b/libgomp/loop.c index 3d1b1ef..58fd9a8 100644 --- a/libgomp/loop.c +++ b/libgomp/loop.c @@ -34,13 +34,14 @@ /* Initialize the given work share construct from the given arguments. */ static inline void -gomp_loop_init (struct gomp_work_share *ws, unsigned long start, - unsigned long end, unsigned long incr, - enum gomp_schedule_type sched, unsigned long chunk_size) +gomp_loop_init (struct gomp_work_share *ws, long start, long end, long incr, + enum gomp_schedule_type sched, long chunk_size) { ws->sched = sched; ws->chunk_size = chunk_size; - ws->end = end; + /* Canonicalize loops that have zero iterations to ->next == ->end. */ + ws->end = ((incr > 0 && start > end) || (incr < 0 && start < end)) + ? start : end; ws->incr = incr; ws->next = start; } @@ -148,9 +149,6 @@ gomp_loop_ordered_static_start (long start, long end, long incr, { struct gomp_thread *thr = gomp_thread (); - if (start == end) - return false; - if (gomp_work_share_start (true)) { gomp_loop_init (thr->ts.work_share, start, end, incr, -- cgit v1.1