aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-02-15 18:42:25 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2008-02-15 18:42:25 +0100
commitac84c0623d12bb99990f34f6bfdf0b17ab976ad6 (patch)
tree00838c45dda5e882688c9dd4d4b72503f4c309c9
parent6a9e85714c092d145293dbb71a748a8ab7b19961 (diff)
downloadgcc-ac84c0623d12bb99990f34f6bfdf0b17ab976ad6.zip
gcc-ac84c0623d12bb99990f34f6bfdf0b17ab976ad6.tar.gz
gcc-ac84c0623d12bb99990f34f6bfdf0b17ab976ad6.tar.bz2
re PR middle-end/35196 (lastprivate broken for static non-ordered loops)
PR middle-end/35196 * omp-low.c (expand_omp_for_generic): Don't initialize fd->v in entry_bb. (expand_omp_for_static_nochunk): Initialize fd->v in seq_start_bb rather than in entry_bb. * testsuite/libgomp.c/pr35196.c: New test. From-SVN: r132351
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/omp-low.c36
-rw-r--r--libgomp/ChangeLog3
-rw-r--r--libgomp/testsuite/libgomp.c/pr35196.c43
4 files changed, 64 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cb73795..42197ab 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2008-02-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/35196
+ * omp-low.c (expand_omp_for_generic): Don't initialize fd->v
+ in entry_bb.
+ (expand_omp_for_static_nochunk): Initialize fd->v in seq_start_bb
+ rather than in entry_bb.
+
2008-02-15 Uros Bizjak <ubizjak@gmail.com>
* config/i386/sfp-machine.h (CMPtype): Define as typedef using
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index ca00266..2e1a1b8 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2782,22 +2782,6 @@ expand_omp_for_generic (struct omp_region *region,
t = build3 (COND_EXPR, void_type_node, t, NULL_TREE, NULL_TREE);
bsi_insert_after (&si, t, BSI_SAME_STMT);
- /* V may be used outside of the loop (e.g., to handle lastprivate clause).
- If this is the case, its value is undefined if the loop is not entered
- at all. To handle this case, set its initial value to N1. */
- if (gimple_in_ssa_p (cfun))
- {
- e = find_edge (entry_bb, l3_bb);
- for (phi = phi_nodes (l3_bb); phi; phi = PHI_CHAIN (phi))
- if (PHI_ARG_DEF_FROM_EDGE (phi, e) == fd->v)
- SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, e), fd->n1);
- }
- else
- {
- t = build_gimple_modify_stmt (fd->v, fd->n1);
- bsi_insert_before (&si, t, BSI_SAME_STMT);
- }
-
/* Remove the OMP_FOR statement. */
bsi_remove (&si, true);
@@ -2995,16 +2979,6 @@ expand_omp_for_static_nochunk (struct omp_region *region,
t = fold_build2 (MIN_EXPR, type, t, n);
e0 = force_gimple_operand_bsi (&si, t, true, NULL_TREE, true, BSI_SAME_STMT);
- t = fold_convert (type, s0);
- t = fold_build2 (MULT_EXPR, type, t, fd->step);
- t = fold_build2 (PLUS_EXPR, type, t, fd->n1);
- t = force_gimple_operand_bsi (&si, t, false, NULL_TREE,
- true, BSI_SAME_STMT);
- t = build_gimple_modify_stmt (fd->v, t);
- bsi_insert_before (&si, t, BSI_SAME_STMT);
- if (gimple_in_ssa_p (cfun))
- SSA_NAME_DEF_STMT (fd->v) = t;
-
t = build2 (GE_EXPR, boolean_type_node, s0, e0);
t = build3 (COND_EXPR, void_type_node, t, NULL_TREE, NULL_TREE);
bsi_insert_before (&si, t, BSI_SAME_STMT);
@@ -3015,6 +2989,16 @@ expand_omp_for_static_nochunk (struct omp_region *region,
/* Setup code for sequential iteration goes in SEQ_START_BB. */
si = bsi_start (seq_start_bb);
+ t = fold_convert (type, s0);
+ t = fold_build2 (MULT_EXPR, type, t, fd->step);
+ t = fold_build2 (PLUS_EXPR, type, t, fd->n1);
+ t = force_gimple_operand_bsi (&si, t, false, NULL_TREE,
+ false, BSI_CONTINUE_LINKING);
+ t = build_gimple_modify_stmt (fd->v, t);
+ bsi_insert_after (&si, t, BSI_CONTINUE_LINKING);
+ if (gimple_in_ssa_p (cfun))
+ SSA_NAME_DEF_STMT (fd->v) = t;
+
t = fold_convert (type, e0);
t = fold_build2 (MULT_EXPR, type, t, fd->step);
t = fold_build2 (PLUS_EXPR, type, t, fd->n1);
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 6a8ba53..44286ca 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,8 @@
2008-02-15 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/35196
+ * testsuite/libgomp.c/pr35196.c: New test.
+
PR middle-end/35130
* testsuite/libgomp.fortran/pr35130.f90: New test.
* testsuite/libgomp.c/pr35130.c: New test.
diff --git a/libgomp/testsuite/libgomp.c/pr35196.c b/libgomp/testsuite/libgomp.c/pr35196.c
new file mode 100644
index 0000000..e92d976
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr35196.c
@@ -0,0 +1,43 @@
+/* PR middle-end/35196 */
+/* { dg-do run } */
+
+extern void abort (void);
+extern void omp_set_dynamic (int);
+
+int
+main (void)
+{
+ int i, j;
+ omp_set_dynamic (0);
+#pragma omp parallel for lastprivate (i, j) num_threads (8) schedule (static)
+ for (i = 0; i < 5; i++)
+ j = i;
+ if (i != 5 || j != 4)
+ abort ();
+#pragma omp parallel for lastprivate (i, j) num_threads (8) schedule (static, 2)
+ for (i = 0; i < 5; i++)
+ j = i;
+ if (i != 5 || j != 4)
+ abort ();
+#pragma omp parallel for lastprivate (i, j) num_threads (8) schedule (dynamic)
+ for (i = 0; i < 5; i++)
+ j = i;
+ if (i != 5 || j != 4)
+ abort ();
+#pragma omp parallel for lastprivate (i, j) num_threads (8) schedule (static)
+ for (i = -12; i < 21; i += 3)
+ j = i;
+ if (i != 21 || j != 18)
+ abort ();
+#pragma omp parallel for lastprivate (i, j) num_threads (8) schedule (static, 2)
+ for (i = -12; i < 21; i += 3)
+ j = i;
+ if (i != 21 || j != 18)
+ abort ();
+#pragma omp parallel for lastprivate (i, j) num_threads (8) schedule (dynamic, 3)
+ for (i = -12; i < 21; i += 3)
+ j = i;
+ if (i != 21 || j != 18)
+ abort ();
+ return 0;
+}