]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/46886 (wrong code with -ftree-parallelize-loops...
authorRichard Guenther <rguenther@suse.de>
Wed, 15 Feb 2012 11:05:26 +0000 (11:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 15 Feb 2012 11:05:26 +0000 (11:05 +0000)
2012-02-15  Richard Guenther  <rguenther@suse.de>

Backport from mainline
2012-02-08  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46886
* tree-flow.h (do_while_loop_p): Declare.
* tree-ssa-loop-ch.c (do_while_loop_p): Export.
* tree-parloops.c (parallelize_loops): Only parallelize do-while
loops.

* testsuite/libgomp.c/pr46886.c: New testcase.

From-SVN: r184263

gcc/ChangeLog
gcc/tree-flow.h
gcc/tree-parloops.c
gcc/tree-ssa-loop-ch.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr46886.c [new file with mode: 0644]

index 084bb1135c4d7e550af29da3d54cc4612f272f10..da9520a4bbefd6e630e3470b8791cb0952ec30d6 100644 (file)
@@ -1,3 +1,14 @@
+2012-02-15  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2012-02-08  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46886
+       * tree-flow.h (do_while_loop_p): Declare.
+       * tree-ssa-loop-ch.c (do_while_loop_p): Export.
+       * tree-parloops.c (parallelize_loops): Only parallelize do-while
+       loops.
+
 2012-02-15  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR target/51921
index 0777aecae72d9901b79be5bcb36ccf5b00cc44f5..77948cd179a26f920009f980e9a5525c44ebd42f 100644 (file)
@@ -611,6 +611,9 @@ extern bool may_propagate_copy (tree, tree);
 extern bool may_propagate_copy_into_stmt (gimple, tree);
 extern bool may_propagate_copy_into_asm (tree);
 
+/* In tree-ssa-loop-ch.c  */
+bool do_while_loop_p (struct loop *);
+
 /* Affine iv.  */
 
 typedef struct
index 9a11f80d4b01198c60075b8d071059af9b35eb09..e9154c37e65c2ab21dfec2de67dbc125b5280c69 100644 (file)
@@ -2132,7 +2132,10 @@ parallelize_loops (void)
          || loop_has_blocks_with_irreducible_flag (loop)
          || (loop_preheader_edge (loop)->src->flags & BB_IRREDUCIBLE_LOOP)
          /* FIXME: the check for vector phi nodes could be removed.  */
-         || loop_has_vector_phi_nodes (loop))
+         || loop_has_vector_phi_nodes (loop)
+         /* FIXME: transform_to_exit_first_loop does not handle not
+            header-copied loops correctly - see PR46886.  */
+         || !do_while_loop_p (loop))
        continue;
       estimated = estimated_loop_iterations_int (loop, false);
       /* FIXME: Bypass this check as graphite doesn't update the
index c58cb5f8bba545ac4d713342d7f8b76d2a591f8f..513745bc2fe9720fb5d4e83da5e45c6f81066845 100644 (file)
@@ -104,7 +104,7 @@ should_duplicate_loop_header_p (basic_block header, struct loop *loop,
 
 /* Checks whether LOOP is a do-while style loop.  */
 
-static bool
+bool
 do_while_loop_p (struct loop *loop)
 {
   gimple stmt = last_stmt (loop->latch);
index f614c41ba77a8a15bf2c4be6bb7688b74813649c..4e681b7e273b49d0f40d657a8c457573374b14d0 100644 (file)
@@ -1,3 +1,11 @@
+2012-02-15  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2012-02-08  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46886
+       * testsuite/libgomp.c/pr46886.c: New testcase.
+
 2011-11-20  Andreas Tobler  <andreast@fgznet.ch>
 
        * configure: Regenerate.
diff --git a/libgomp/testsuite/libgomp.c/pr46886.c b/libgomp/testsuite/libgomp.c/pr46886.c
new file mode 100644 (file)
index 0000000..fbdc4e1
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O -ftree-parallelize-loops=4 -fno-tree-ch -fno-tree-dominator-opts" } */
+
+void abort(void);
+
+int d[1024], e[1024];
+
+int foo (void)
+{
+  int s = 0;
+  int i;
+  for (i = 0; i < 1024; i++)
+    s += d[i] - e[i];
+  return s;
+}
+
+int main ()
+{
+  int i;
+  for (i = 0; i < 1024; i++)
+    {
+      d[i] = i * 2;
+      e[i] = i;
+    }
+  if (foo () != 1023 * 1024 / 2)
+    abort ();
+  return 0;
+}