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]

More profile updating fixes


Hi,
bootstrapping with profile feedback at tree level uncovers two extra crashes
due to roundoff errors (in jump threading case the sum of probabilities
ends up slightly greater than REG_BR_PROB_BASE, in the second case the
loop header is copied but profile is already in conflict.  There is also
one uninitialized variable warning that is valid and I am unsure why it
didn't trigger originally.

Bootstapped/regtested i686-pc-gnu-linux, comitted.
Honza

2005-07-16  Jan Hubicka  <jh@suse.cz>
	* cfg.c (update_bb_profile_for_threading): Fix profile updating.
	(scale_bbs_frequencies_int): Watch roundoff errors.
	* predict.c (return_prediction): Initialize return_stmt.
Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.100
diff -c -3 -p -r1.100 cfg.c
*** cfg.c	15 Jul 2005 09:46:16 -0000	1.100
--- cfg.c	15 Jul 2005 21:50:09 -0000
*************** update_bb_profile_for_threading (basic_b
*** 896,902 ****
        int scale = 65536 * REG_BR_PROB_BASE / prob;
  
        FOR_EACH_EDGE (c, ei, bb->succs)
! 	c->probability = (c->probability * scale) / 65536;
      }
  
    gcc_assert (bb == taken_edge->src);
--- 896,906 ----
        int scale = 65536 * REG_BR_PROB_BASE / prob;
  
        FOR_EACH_EDGE (c, ei, bb->succs)
! 	{
! 	  c->probability = (c->probability * scale) / 65536;
! 	  if (c->probability > REG_BR_PROB_BASE)
! 	    c->probability = REG_BR_PROB_BASE;
! 	}
      }
  
    gcc_assert (bb == taken_edge->src);
*************** scale_bbs_frequencies_int (basic_block *
*** 917,922 ****
--- 921,930 ----
  {
    int i;
    edge e;
+   if (num < 0)
+     num = 0;
+   if (num > den)
+     return;
    for (i = 0; i < nbbs; i++)
      {
        edge_iterator ei;
Index: predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.152
diff -c -3 -p -r1.152 predict.c
*** predict.c	26 Jun 2005 21:21:26 -0000	1.152
--- predict.c	15 Jul 2005 21:50:10 -0000
*************** return_prediction (tree val, enum predic
*** 1206,1212 ****
  static void
  apply_return_prediction (int *heads)
  {
!   tree return_stmt;
    tree return_val;
    edge e;
    tree phi;
--- 1206,1212 ----
  static void
  apply_return_prediction (int *heads)
  {
!   tree return_stmt = NULL;
    tree return_val;
    edge e;
    tree phi;


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