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]

another jump threading bug :(



Hi,
this patch fixes another bug in the jump threading - the nthreaded_edges
is not cleared for each edge forwarded so sometimes if multiple edges
from singe BB are threaded, we die by getting out of sync.

I've also fixed updating of probabilities after threading is done - this
is usefull to keep profile feedback in shape.

Bootstrtapped/regtested i386.

Honza

Mit Jan  9 17:39:08 CET 2002  Jan Hubicka  <jh@suse.cz>
	* (try_forward_edges):  Properly initialize nthreaded_edges;
	update edge probabilities to match.

Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cfgcleanup.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 cfgcleanup.c
*** cfgcleanup.c	2002/01/07 02:14:30	1.34
--- cfgcleanup.c	2002/01/09 16:38:50
*************** try_forward_edges (mode, b)
*** 370,382 ****
  {
    bool changed = false;
    edge e, next, *threaded_edges = NULL;
-   int nthreaded_edges = 0;
  
    for (e = b->succ; e; e = next)
      {
        basic_block target, first;
        int counter;
        bool threaded = false;
  
        next = e->succ_next;
  
--- 370,382 ----
  {
    bool changed = false;
    edge e, next, *threaded_edges = NULL;
  
    for (e = b->succ; e; e = next)
      {
        basic_block target, first;
        int counter;
        bool threaded = false;
+       int nthreaded_edges = 0;
  
        next = e->succ_next;
  
*************** try_forward_edges (mode, b)
*** 521,536 ****
  	      edge t;
  
  	      first->count -= edge_count;
- 	      first->succ->count -= edge_count;
  	      first->frequency -= edge_frequency;
  	      if (first->succ->succ_next)
  		{
  		  if (n >= nthreaded_edges)
  		    abort ();
  		  t = threaded_edges [n++];
  		}
  	      else
! 		t = first->succ;
  
  	      first = t->dest;
  	    }
--- 521,557 ----
  	      edge t;
  
  	      first->count -= edge_count;
  	      first->frequency -= edge_frequency;
  	      if (first->succ->succ_next)
  		{
+ 		  edge e;
+ 		  int prob;
  		  if (n >= nthreaded_edges)
  		    abort ();
  		  t = threaded_edges [n++];
+ 		  if (t->src != first)
+ 		    abort ();
+ 		  if (first->frequency)
+ 		    prob = edge_frequency * REG_BR_PROB_BASE / first->frequency;
+ 		  else
+ 		    prob = 0;
+ 		  t->probability -= prob;
+ 		  for (e = first->succ; e; e = e->succ_next)
+ 		    e->probability = ((e->probability * REG_BR_PROB_BASE)
+ 				      / (double) (REG_BR_PROB_BASE - prob));
  		}
  	      else
! 		{
! 		  /* It is possible that as the result of
! 		     threading we've removed edge as it is
! 		     threaded to the fallthru edge.  Avoid
! 		     getting out of sync.  */
! 		  if (n < nthreaded_edges
! 		      && first == threaded_edges [n]->src)
! 		    n++;
! 		  t = first->succ;
! 		 }
! 	      t->count -= edge_count;
  
  	      first = t->dest;
  	    }


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