[commited] profile updating

Jan Hubicka jh@suse.cz
Fri Sep 10 09:28:00 GMT 2004


Hi,
this patch merge more trivial profile updating bits from tree-profiling patch.
There is still one hunk into dom's jump threading code missing.  I sent it
earlier and Rth asked for more code sharing in between this and cfgcleanup.c so
I feel unconfortable about commiting it as it is now.  I am looking into how
much I can do on this path (this is surprisingly uneasy as both jump threaders
do the changes to CFG in very different and convoluted ways)

Bootstrapped/regtested i686-pc-gnu-linux and ppc-linux with checking and commited.

I would now kindly request the developers to care updating profile.  It is very
dificult to audit the code and add updating afterwards.  With the new sanity
checking you get warnings output to the dumps so it should be easy to notice
when something is wrong.

Honza

2004-09-10  Jan Hubicka  <jh@suse.cz>
	* tree-ssa-dce.c (remove_dead_stmt): Update profile.
	* tree-split_edge.c (tree_split_edge): Likewise.
	(thread_jumps): Likewise.
Index: tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dce.c,v
retrieving revision 2.13
diff -c -3 -p -r2.13 tree-ssa-dce.c
*** tree-ssa-dce.c	25 Aug 2004 21:21:16 -0000	2.13
--- tree-ssa-dce.c	7 Sep 2004 13:27:05 -0000
*************** remove_dead_stmt (block_stmt_iterator *i
*** 761,766 ****
--- 762,769 ----
        /* Redirect the first edge out of BB to reach POST_DOM_BB.  */
        redirect_edge_and_branch (bb->succ, post_dom_bb);
        PENDING_STMT (bb->succ) = NULL;
+       bb->succ->probability = REG_BR_PROB_BASE;
+       bb->succ->count = bb->count;
  
        /* The edge is no longer associated with a conditional, so it does
  	 not have TRUE/FALSE flags.  */
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.43
diff -c -3 -p -r2.43 tree-cfg.c
*** tree-cfg.c	25 Aug 2004 21:21:12 -0000	2.43
--- tree-cfg.c	7 Sep 2004 13:27:02 -0000
*************** tree_split_edge (edge edge_in)
*** 3035,3041 ****
--- 3032,3042 ----
      after_bb = edge_in->src;
  
    new_bb = create_empty_bb (after_bb);
+   new_bb->frequency = EDGE_FREQUENCY (edge_in);
+   new_bb->count = edge_in->count;
    new_edge = make_edge (new_bb, dest, EDGE_FALLTHRU);
+   new_edge->probability = REG_BR_PROB_BASE;
+   new_edge->count = edge_in->count;
  
    /* Find all the PHI arguments on the original edge, and change them to
       the new edge.  Do it before redirection, so that the argument does not
*************** thread_jumps (void)
*** 3872,3877 ****
--- 3873,3880 ----
  	 forwardable.  */
        for (e = bb->succ; e; e = next)
  	{
+ 	  int freq;
+ 	  gcov_type count;
  	  next = e->succ_next;
  
  	  /* If the edge is abnormal or its destination is not
*************** thread_jumps (void)
*** 3880,3885 ****
--- 3883,3891 ----
  	      || !tree_forwarder_block_p (e->dest))
  	    continue;
  
+ 	  count = e->count;
+ 	  freq = EDGE_FREQUENCY (e);
+ 
  	  /* Now walk through as many forwarder block as possible to
  	     find the ultimate destination we want to thread our jump
  	     to.  */
*************** thread_jumps (void)
*** 3899,3904 ****
--- 3905,3919 ----
  		break;
  
  	      bb_ann (dest)->forwardable = 0;
+ 	      dest->frequency -= freq;
+ 	      if (dest->frequency < 0)
+ 		dest->frequency = 0;
+ 	      dest->count -= count;
+ 	      if (dest->count < 0)
+ 		dest->count = 0;
+ 	      dest->succ->count -= count;
+ 	      if (dest->succ->count < 0)
+ 		dest->succ->count = 0;
  	    }
  
  	  /* Reset the forwardable marks to 1.  */



More information about the Gcc-patches mailing list