This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[cfg-branch] STC - avoid some duplications


Hi,

this patch avoids duplicating a BB when the destination of the selected edge is also the source of the selected edge.
This avoids unneeded duplication in this situation:

edges:
1->2
2->2
2->3

The previous version created:
1->2
2->3
2->2'
2'->2
2'->3'

This patch avoids the duplications and leaves the flow graph as described in the top.

Bootstrapped on i386.


2001-12-15  Josef Zlomek  <zlomek@matfyz.cz>

	* bb-reorder.c (find_traces_1_round): Avoid duplication then the destination of the selected edge is also the source.


*** gcc-cvs/gcc/bb-reorder.c	Sat Dec 15 11:40:48 2001
--- gcc/gcc/bb-reorder.c	Sat Dec 15 12:43:34 2001
*************** find_traces_1_round (branch_th, exec_th,
*** 144,149 ****
--- 144,151 ----
       fibheap_t *heap;
       bool size_can_grow;
  {
+   bool pretended_duplication = false;
+ 
    /* Heap for discarded basic blocks which are possible starting points for
       the next round.  */
    fibheap_t new_heap = fibheap_new ();
*************** find_traces_1_round (branch_th, exec_th,
*** 294,303 ****
  		}
  	    }
  
  	  if (best_edge)
  	    /* Found suitable successor.  */
  	    {
! 	      if (RBI (best_edge->dest)->visited)
  		{
  		  basic_block new_bb, old_bb;
  
--- 296,324 ----
  		}
  	    }
  
+ 	  /* Now we have selected the successor so we can clean the flags that
+ 	     this BB was pretended to be duplicated so that the debug output
+ 	     was correct.  */
+ 	  if (pretended_duplication)
+ 	    {
+ 	      pretended_duplication = false;
+ 	      RBI (bb)->duplicated = 0;
+ 	      RBI (bb)->original = NULL;
+ 	    }
+ 	  
  	  if (best_edge)
  	    /* Found suitable successor.  */
  	    {
! 	      if (best_edge->dest == bb)
! 		{
! 		  /* We do not want to duplicate the BB which is its own
! 		     successor.  Pretend it was duplicated so that the other
! 		     code worked as BB was duplicated.  */
! 		  RBI (bb)->original = bb;
! 		  RBI (bb)->duplicated = *n_traces;
! 		  pretended_duplication = true;
! 		}
! 	      else if (RBI (best_edge->dest)->visited)
  		{
  		  basic_block new_bb, old_bb;
  
*************** find_traces_1_round (branch_th, exec_th,
*** 308,314 ****
  		  if (RBI (best_edge->dest)->visited)
  		    abort ();
  		  if (rtl_dump_file)
! 		    fprintf (rtl_dump_file, "Duplicated bb %d (created bb %d)\n",
  			     old_bb->index, new_bb->index);
  		  RBI (old_bb)->duplicated = *n_traces;
  		  RBI (bb)->next = new_bb;
--- 329,336 ----
  		  if (RBI (best_edge->dest)->visited)
  		    abort ();
  		  if (rtl_dump_file)
! 		    fprintf (rtl_dump_file,
! 			     "Duplicated bb %d (created bb %d)\n",
  			     old_bb->index, new_bb->index);
  		  RBI (old_bb)->duplicated = *n_traces;
  		  RBI (bb)->next = new_bb;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]