[rtlopt] bb-reorder - update keys when they change

Josef Zlomek zlomj9am@artax.karlin.mff.cuni.cz
Wed Dec 4 08:35:00 GMT 2002


Hi,

this patch causes that the heap keys are updated each time when they can
change (updating keys after the termination of trace is now done too).

Bootstrapped i386.

Josef


Wed Dec  4 17:34:01 CET 2002  Josef Zlomek <zlomj9am@artax.karlin.mff.cuni.cz>

	* bb-reorder.c (find_traces_1_round): update the keys also after
	terminating the trace.

Index: gcc/bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.50.2.8
diff -u -c -3 -p -r1.50.2.8 bb-reorder.c
*** gcc/bb-reorder.c	27 Nov 2002 17:04:43 -0000	1.50.2.8
--- gcc/bb-reorder.c	4 Dec 2002 14:32:18 -0000
*************** find_traces_1_round (branch_th, exec_th,
*** 259,264 ****
--- 259,266 ----
        basic_block bb;
        struct trace *trace;
        edge best_edge, e;
+       int bb_index;
+       fibheapkey_t key;
  
        bb = fibheap_extract_min (*heap);
        bb_heap[bb->index] = NULL;
*************** find_traces_1_round (branch_th, exec_th,
*** 338,352 ****
  	  /* Add all nonselected successors to the heaps.  */
  	  for (e = bb->succ; e; e = e->succ_next)
  	    {
- 	      int bb_index = e->dest->index;
- 	      fibheapkey_t key;
- 
  	      if (e == best_edge
  		  || e->dest == EXIT_BLOCK_PTR
  		  || RBI (e->dest)->visited)
  		continue;
  
  	      key = bb_to_key (e->dest);
  
  	      if (bb_heap[bb_index])
  		{
--- 340,352 ----
  	  /* Add all nonselected successors to the heaps.  */
  	  for (e = bb->succ; e; e = e->succ_next)
  	    {
  	      if (e == best_edge
  		  || e->dest == EXIT_BLOCK_PTR
  		  || RBI (e->dest)->visited)
  		continue;
  
  	      key = bb_to_key (e->dest);
+ 	      bb_index = e->dest->index;
  
  	      if (bb_heap[bb_index])
  		{
*************** find_traces_1_round (branch_th, exec_th,
*** 512,517 ****
--- 512,544 ----
        trace->last = bb;
        start_of_trace[trace->first->index] = *n_traces - 1;
        end_of_trace[trace->last->index] = *n_traces - 1;
+ 
+       /* The trace is terminated so we have to recount the keys in heap
+ 	 (some block can have a lower key because now one of its predecessors is
+ 	 an end of trace.  */
+       for (e = bb->succ; e; e = e->succ_next)
+ 	{
+ 	  if (e->dest == EXIT_BLOCK_PTR
+ 	      || RBI (e->dest)->visited)
+ 	    continue;
+ 	  
+ 	  bb_index = e->dest->index;
+ 	  if (bb_heap[bb_index])
+ 	    {
+ 	      key = bb_to_key (e->dest);
+ 	      if (key != bb_node[bb_index]->key)
+ 		{
+ 		  if (rtl_dump_file)
+ 		    {
+ 		      fprintf (rtl_dump_file,
+ 			       "Changing key for bb %d from %ld to %ld.\n",
+ 			       bb_index, (long) bb_node[bb_index]->key, key);
+ 		    }
+ 		  fibheap_replace_key (bb_heap[bb_index], bb_node[bb_index],
+ 				       key);
+ 		}
+ 	    }
+ 	}
      }
  
    fibheap_delete (*heap);



More information about the Gcc-patches mailing list