]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/61607 (DOM missed jump threading and destroyed loops)
authorRichard Biener <rguenther@suse.de>
Thu, 26 Jun 2014 07:44:10 +0000 (07:44 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 26 Jun 2014 07:44:10 +0000 (07:44 +0000)
2014-06-26  Richard Biener  <rguenther@suse.de>

PR tree-optimization/61607
* tree-ssa-threadupdate.c (ssa_redirect_edges): Cancel the
loop if we redirected its latch edge.
(thread_block_1): Do not cancel loops prematurely.

From-SVN: r212011

gcc/ChangeLog
gcc/tree-ssa-threadupdate.c

index ba0f83231d5711a4f9ab14ef379fc5ba75d96d39..d26b93e5402ba4ed2df4fe1b5ec7a983eba31412 100644 (file)
@@ -1,3 +1,10 @@
+2014-06-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61607
+       * tree-ssa-threadupdate.c (ssa_redirect_edges): Cancel the
+       loop if we redirected its latch edge.
+       (thread_block_1): Do not cancel loops prematurely.
+
 2014-06-25  Jan Hubicka  <hubicka@ucw.cz>
 
        * toplev.c (backend_init_target): Move init_emit_regs and init_regs to...
index 02cf42c0da0c51d75e1c27222eb3d16259ff1791..a0b1be544adf358729e2675cb26405fe1b105e4f 100644 (file)
@@ -764,6 +764,14 @@ ssa_redirect_edges (struct redirection_data **slot,
          if ((*path)[1]->type != EDGE_COPY_SRC_JOINER_BLOCK)
            EDGE_SUCC (rd->dup_blocks[0], 0)->count += e->count;
 
+         /* If we redirect a loop latch edge cancel its loop.  */
+         if (e->src == e->src->loop_father->latch)
+           {
+             e->src->loop_father->header = NULL;
+             e->src->loop_father->latch = NULL;
+             loops_state_set (LOOPS_NEED_FIXUP);
+           }
+
          /* Redirect the incoming edge (possibly to the joiner block) to the
             appropriate duplicate block.  */
          e2 = redirect_edge_and_branch (e, rd->dup_blocks[0]);
@@ -844,7 +852,6 @@ thread_block_1 (basic_block bb, bool noloop_only, bool joiners)
   edge e, e2;
   edge_iterator ei;
   ssa_local_info_t local_info;
-  struct loop *loop = bb->loop_father;
 
   /* To avoid scanning a linear array for the element we need we instead
      use a hash table.  For normal code there should be no noticeable
@@ -853,32 +860,6 @@ thread_block_1 (basic_block bb, bool noloop_only, bool joiners)
   redirection_data
     = new hash_table<struct redirection_data> (EDGE_COUNT (bb->succs));
 
-  /* If we thread the latch of the loop to its exit, the loop ceases to
-     exist.  Make sure we do not restrict ourselves in order to preserve
-     this loop.  */
-  if (loop->header == bb)
-    {
-      e = loop_latch_edge (loop);
-      vec<jump_thread_edge *> *path = THREAD_PATH (e);
-
-      if (path
-         && (((*path)[1]->type == EDGE_COPY_SRC_JOINER_BLOCK && joiners)
-             || ((*path)[1]->type == EDGE_COPY_SRC_BLOCK && !joiners)))
-       {
-         for (unsigned int i = 1; i < path->length (); i++)
-           {
-             edge e2 = (*path)[i]->e;
-
-             if (loop_exit_edge_p (loop, e2))
-               {
-                 loop->header = NULL;
-                 loop->latch = NULL;
-                 loops_state_set (LOOPS_NEED_FIXUP);
-               }
-           }
-       }
-    }
-
   /* Record each unique threaded destination into a hash table for
      efficient lookups.  */
   FOR_EACH_EDGE (e, ei, bb->preds)