]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/54520 (ice in merge_latch_edges with -O3)
authorRichard Guenther <rguenther@suse.de>
Mon, 10 Sep 2012 14:10:09 +0000 (14:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 10 Sep 2012 14:10:09 +0000 (14:10 +0000)
2012-09-10  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/54520
* tree-ssa-threadupdate.c (def_split_header_continue_p):
Properly consider sub-loops.

* gcc.dg/torture/pr54520.c: New testcase.

From-SVN: r191141

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr54520.c [new file with mode: 0644]
gcc/tree-ssa-threadupdate.c

index 6e7175afd3fdbd56d2a365e96a5cd7803e3db235..0e0bc2bdcec5d379f60f104c7183389907306bc1 100644 (file)
@@ -1,3 +1,9 @@
+2012-09-10  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/54520
+       * tree-ssa-threadupdate.c (def_split_header_continue_p):
+       Properly consider sub-loops.
+
 2012-09-10  Richard Henderson  <rth@redhat.com>
 
        * config/alpha/predicates.md (small_symbolic_operand): Disallow
index 65e31bd880488fec70d24b8f385fde182fda7467..bd4b362c188a656fd537c9f94f526d1cba62efcb 100644 (file)
@@ -1,3 +1,8 @@
+2012-09-10  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/54520
+       * gcc.dg/torture/pr54520.c: New testcase.
+
 2012-09-10  Jason Merrill  <jason@redhat.com>
 
        PR c++/54506
diff --git a/gcc/testsuite/gcc.dg/torture/pr54520.c b/gcc/testsuite/gcc.dg/torture/pr54520.c
new file mode 100644 (file)
index 0000000..5884b2f
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+char *a;
+void
+fn1 ()
+{
+  char *p = a;
+  while (p && *p != '\0')
+    {
+      while (*p == '\t')
+       *p++ = '\0';
+      if (*p != '\0')
+       p = 0;
+    }
+}
index 30336a18e81ff713ca7ea4f616036419696a58ee..ba6d69af9428603a6ea74011d84ec0cd87c54972 100644 (file)
@@ -846,8 +846,9 @@ static bool
 def_split_header_continue_p (const_basic_block bb, const void *data)
 {
   const_basic_block new_header = (const_basic_block) data;
-  return (bb->loop_father == new_header->loop_father
-         && bb != new_header);
+  return (bb != new_header
+         && (loop_depth (bb->loop_father)
+             >= loop_depth (new_header->loop_father)));
 }
 
 /* Thread jumps through the header of LOOP.  Returns true if cfg changes.
@@ -1031,10 +1032,11 @@ thread_through_loop_header (struct loop *loop, bool may_peel_loop_headers)
       nblocks = dfs_enumerate_from (header, 0, def_split_header_continue_p,
                                    bblocks, loop->num_nodes, tgt_bb);
       for (i = 0; i < nblocks; i++)
-       {
-         remove_bb_from_loops (bblocks[i]);
-         add_bb_to_loop (bblocks[i], loop_outer (loop));
-       }
+       if (bblocks[i]->loop_father == loop)
+         {
+           remove_bb_from_loops (bblocks[i]);
+           add_bb_to_loop (bblocks[i], loop_outer (loop));
+         }
       free (bblocks);
 
       /* If the new header has multiple latches mark it so.  */