https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72772

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
FAIL: gcc.dg/tree-ssa/20030714-2.c scan-tree-dump-times dom2 "if " 3

is because jump-threading doesn't want to thread to a loop header and w/o the
patch we have a pre-header with the degenerate PHI which causes it to stop
there.  With the patch we have an empty pre-header which is threaded as well
and thus threading fails.  We hit

          /* One case occurs when there was loop header buried in a jump
             threading path that crosses loop boundaries.  We do not try
             and thread this elsewhere, so just cancel the jump threading
             request by clearing the AUX field now.  */
          if ((bb->loop_father != e2->src->loop_father
               && !loop_exit_edge_p (e2->src->loop_father, e2))
              || (e2->src->loop_father != e2->dest->loop_father
                  && !loop_exit_edge_p (e2->src->loop_father, e2)))
            {
              /* Since this case is not handled by our special code
                 to thread through a loop header, we must explicitly
                 cancel the threading request here.  */
              delete_jump_thread_path (path);
              e->aux = NULL;
              continue;
            }

as e2 is the loop entry edge.

  Registering jump thread: (3, 5) incoming edge;  (5, 8) normal; (8, 6) nocopy;

and 8->6 is this edge while 8 is the loop preheader.  Not sure why we
have the above 2nd condition.  Not sure why, if we have this condition,
we do not simply drop the tail of this path.  It looks like
mark_threaded_blocks
would fix this up if the crossed_header check would be >= 1 and not just > 1.

Index: gcc/tree-ssa-threadupdate.c
===================================================================
--- gcc/tree-ssa-threadupdate.c (revision 239117)
+++ gcc/tree-ssa-threadupdate.c (working copy)
@@ -1531,10 +1531,8 @@ thread_block_1 (basic_block bb, bool nol
             threading path that crosses loop boundaries.  We do not try
             and thread this elsewhere, so just cancel the jump threading
             request by clearing the AUX field now.  */
-         if ((bb->loop_father != e2->src->loop_father
-              && !loop_exit_edge_p (e2->src->loop_father, e2))
-             || (e2->src->loop_father != e2->dest->loop_father
-                 && !loop_exit_edge_p (e2->src->loop_father, e2)))
+         if (bb->loop_father != e2->src->loop_father
+             && !loop_exit_edge_p (e2->src->loop_father, e2))
            {
              /* Since this case is not handled by our special code
                 to thread through a loop header, we must explicitly

fixes this testcase.

Reply via email to