diff mbox

[PR,tree-optimization/77424] Cleanup remnants of threading through backedges in old threader

Message ID 24d895b2-e9e6-231b-6ddd-8fc3413b53c9@redhat.com
State New
Headers show

Commit Message

Jeff Law Oct. 11, 2016, 9:42 p.m. UTC
As Jon pointed out in the BZ, there's an if-else in 
tree-ssa-threadupdate.c where the if and else blocks are equivalent. 
Clearly that's all that useful.

The code in question used to be an if-elseif-else construct where the 
elseif block did something different.  The elseif block was removed when 
I removed support for threading through backedges in the old threader.

I missed the secondary cleanup, namely that the entire block of code is 
no longer as very recorded jump thread should have been explicitly 
realized or removed.

This patch verifies that indeed all the requested jump threads are 
explicitly handled by asserting that e->aux (which holds the jump thread 
request) is NULL at this point in the code.

Bootstrapped and regression tested on x86_64-linux-gnu.  Installed on 
the trunk.

Jeff
commit 85aac4bc9828ed43fb24cd2b63ca9130b485dd80
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Oct 11 21:41:51 2016 +0000

    	PR tree-optimization/77424
    	* tree-ssa-threadupdate.c (thread_through_all_blocks): Remove
    	dead conditionals.  Assert that all e->aux fields are NULL.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241009 138bc75d-0d04-0410-961f-82ee72b054a4
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d555c2e..e7b5b0b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@ 
+2016-10-11  Jeff Law  <law@redhat.com>
+
+	PR tree-optimization/77424
+	* tree-ssa-threadupdate.c (thread_through_all_blocks): Remove
+	dead conditionals.  Assert that all e->aux fields are NULL.
+
 2016-10-11  David Malcolm  <dmalcolm@redhat.com>
 
 	* print-rtl.c (print_rtx): Rename "i" to "idx".  Split out the
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 66d919c..325cb0b 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -2550,55 +2550,15 @@  thread_through_all_blocks (bool may_peel_loop_headers)
       retval |= thread_through_loop_header (loop, may_peel_loop_headers);
     }
 
-  /* Any jump threading paths that are still attached to edges at this
-     point must be one of two cases.
-
-     First, we could have a jump threading path which went from outside
-     a loop to inside a loop that was ignored because a prior jump thread
-     across a backedge was realized (which indirectly causes the loop
-     above to ignore the latter thread).  We can detect these because the
-     loop structures will be different and we do not currently try to
-     optimize this case.
-
-     Second, we could be threading across a backedge to a point within the
-     same loop.  This occurrs for the FSA/FSM optimization and we would
-     like to optimize it.  However, we have to be very careful as this
-     may completely scramble the loop structures, with the result being
-     irreducible loops causing us to throw away our loop structure.
-
-     As a compromise for the latter case, if the thread path ends in
-     a block where the last statement is a multiway branch, then go
-     ahead and thread it, else ignore it.  */
+  /* All jump threading paths should have been resolved at this
+     point.  Verify that is the case.  */
   basic_block bb;
-  edge e;
   FOR_EACH_BB_FN (bb, cfun)
     {
-      /* If we do end up threading here, we can remove elements from
-	 BB->preds.  Thus we can not use the FOR_EACH_EDGE iterator.  */
-      for (edge_iterator ei = ei_start (bb->preds);
-	   (e = ei_safe_edge (ei));)
-	if (e->aux)
-	  {
-	    vec<jump_thread_edge *> *path = THREAD_PATH (e);
-
-	    /* Case 1, threading from outside to inside the loop
-	       after we'd already threaded through the header.  */
-	    if ((*path)[0]->e->dest->loop_father
-		!= path->last ()->e->src->loop_father)
-	      {
-		delete_jump_thread_path (path);
-		e->aux = NULL;
-		ei_next (&ei);
-	      }
-	    else
-	      {
-		delete_jump_thread_path (path);
-		e->aux = NULL;
-		ei_next (&ei);
-	      }
- 	  }
-	else
-	  ei_next (&ei);
+      edge_iterator ei;
+      edge e;
+      FOR_EACH_EDGE (e, ei, bb->preds)
+	gcc_assert (e->aux == NULL);
     }
 
   statistics_counter_event (cfun, "Jumps threaded",