aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2010-04-21 15:58:59 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2010-04-21 15:58:59 +0200
commit7662eaba51172b47ac66c11e1618692c2ad9cdb3 (patch)
tree24d86e5a493a673e7b5231b40b95be7718e82ace /libgomp
parent44d283bc232f4f3e71666170a8ea5fa2468816f7 (diff)
re PR libgomp/43569 (libgomp: Conditional jump or move depends on uninitialised value)
PR libgomp/43569 * sections.c (gomp_sections_init): Initialize ws->mode. From-SVN: r158599
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog5
-rw-r--r--libgomp/sections.c20
2 files changed, 23 insertions, 2 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 8a26d5533ab..ff20f429b06 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgomp/43569
+ * sections.c (gomp_sections_init): Initialize ws->mode.
+
2010-03-22 Jakub Jelinek <jakub@redhat.com>
PR libgomp/42942
diff --git a/libgomp/sections.c b/libgomp/sections.c
index 7acd441de53..c7f49b7c32a 100644
--- a/libgomp/sections.c
+++ b/libgomp/sections.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -34,9 +34,25 @@ gomp_sections_init (struct gomp_work_share *ws, unsigned count)
{
ws->sched = GFS_DYNAMIC;
ws->chunk_size = 1;
- ws->end = count + 1;
+ ws->end = count + 1L;
ws->incr = 1;
ws->next = 1;
+#ifdef HAVE_SYNC_BUILTINS
+ /* Prepare things to make each iteration faster. */
+ if (sizeof (long) > sizeof (unsigned))
+ ws->mode = 1;
+ else
+ {
+ struct gomp_thread *thr = gomp_thread ();
+ struct gomp_team *team = thr->ts.team;
+ long nthreads = team ? team->nthreads : 1;
+
+ ws->mode = ((nthreads | ws->end)
+ < 1UL << (sizeof (long) * __CHAR_BIT__ / 2 - 1));
+ }
+#else
+ ws->mode = 0;
+#endif
}
/* This routine is called when first encountering a sections construct