aboutsummaryrefslogtreecommitdiff
path: root/libgomp/loop.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-12-04 11:26:00 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2006-12-04 11:26:00 +0100
commit22568cc62cabbea1eec20ef65e1da9b0caaa6f02 (patch)
treef94786a4fcf50b6049962a9a01cc79e07e724e65 /libgomp/loop.c
parentd3c673c74acfcc0202b0013677ef280e76fffb72 (diff)
downloadgcc-22568cc62cabbea1eec20ef65e1da9b0caaa6f02.zip
gcc-22568cc62cabbea1eec20ef65e1da9b0caaa6f02.tar.gz
gcc-22568cc62cabbea1eec20ef65e1da9b0caaa6f02.tar.bz2
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
Diffstat (limited to 'libgomp/loop.c')
-rw-r--r--libgomp/loop.c12
1 files changed, 5 insertions, 7 deletions
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,