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]

Fix one of problems in profile updating code


Jeff,
with one of updates you killed code computing counts of duplicated block
in thread updating code.  Please try to mind profile when modifying the
code further as it is getting bit dificult to figure out what jump
threading does and how to fix it and the code broke several times in the
past.  This bug was responsible for quite large regression of art
benchmark and there still seems to be other problem described in
PR22401.

I've bootstrapped/regtested on i686 and commited the attached patch.

Honza

2005-07-15  Jan Hubicka  <jh@suse.cz>
	* cfg.c (update_bb_profile_for_threading): More diagnostic.
	* tree-ssa-threadupdate.c (redirect_edges): Update profile of dup_block.
Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.99
diff -c -3 -p -r1.99 cfg.c
*** cfg.c	27 Jun 2005 23:06:32 -0000	1.99
--- cfg.c	14 Jul 2005 21:46:46 -0000
*************** update_bb_profile_for_threading (basic_b
*** 850,856 ****
  
    bb->count -= count;
    if (bb->count < 0)
!     bb->count = 0;
  
    /* Compute the probability of TAKEN_EDGE being reached via threaded edge.
       Watch for overflows.  */
--- 850,861 ----
  
    bb->count -= count;
    if (bb->count < 0)
!     {
!       if (dump_file)
! 	fprintf (dump_file, "bb %i count became negative after threading",
! 		 bb->index);
!       bb->count = 0;
!     }
  
    /* Compute the probability of TAKEN_EDGE being reached via threaded edge.
       Watch for overflows.  */
*************** update_bb_profile_for_threading (basic_b
*** 897,903 ****
    gcc_assert (bb == taken_edge->src);
    taken_edge->count -= count;
    if (taken_edge->count < 0)
!     taken_edge->count = 0;
  }
  
  /* Multiply all frequencies of basic blocks in array BBS of length NBBS
--- 902,913 ----
    gcc_assert (bb == taken_edge->src);
    taken_edge->count -= count;
    if (taken_edge->count < 0)
!     {
!       if (dump_file)
! 	fprintf (dump_file, "edge %i->%i count became negative after threading",
! 		 taken_edge->src->index, taken_edge->dest->index);
!       taken_edge->count = 0;
!     }
  }
  
  /* Multiply all frequencies of basic blocks in array BBS of length NBBS
Index: tree-ssa-threadupdate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-threadupdate.c,v
retrieving revision 2.31
diff -c -3 -p -r2.31 tree-ssa-threadupdate.c
*** tree-ssa-threadupdate.c	25 Jun 2005 02:01:47 -0000	2.31
--- tree-ssa-threadupdate.c	14 Jul 2005 21:47:14 -0000
*************** redirect_edges (void **slot, void *data)
*** 609,614 ****
--- 609,617 ----
  	    fprintf (dump_file, "  Threaded jump %d --> %d to %d\n",
  		     e->src->index, e->dest->index, rd->dup_block->index);
  
+ 	  rd->dup_block->count += e->count;
+ 	  rd->dup_block->frequency += EDGE_FREQUENCY (e);
+ 	  EDGE_SUCC (rd->dup_block, 0)->count += e->count;
  	  /* Redirect the incoming edge to the appropriate duplicate
  	     block.  */
  	  e2 = redirect_edge_and_branch (e, rd->dup_block);


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