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]

[cfg-branch] tracer tweeks


Hi,
this patch limits tracing in cases static predictor is unsure about branch
outcome and for the badly predictable branches, where tracing may just waste
code size and interfere badly with if converison pass.


Mon Dec 31 15:37:14 CET 2001  Jan Hubicka  <jh@suse.cz>
	* cfgcleanup.c (outgoing_edges_match): Add debug output.
	* tracer.c (MIN_COUNT, MIN_FREQUENCY): Kill.
	(MIN_BRANCH_PROBABILITY): New macro.
	(find_best_successor): Use it.
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cfgcleanup.c,v
retrieving revision 1.18.2.14
diff -c -3 -p -r1.18.2.14 cfgcleanup.c
*** cfgcleanup.c	2001/12/31 13:47:10	1.18.2.14
--- cfgcleanup.c	2001/12/31 14:32:36
*************** outgoing_edges_match (mode, bb1, bb2)
*** 1085,1091 ****
  	  /* Fail if the difference in probabilities is
  	     greater than 5%.  */
  	  if (abs (b1->probability - prob2) > REG_BR_PROB_BASE / 20)
! 	    return false;
  	}
  
        if (rtl_dump_file && match)
--- 1085,1098 ----
  	  /* Fail if the difference in probabilities is
  	     greater than 5%.  */
  	  if (abs (b1->probability - prob2) > REG_BR_PROB_BASE / 20)
! 	    {
! 	      if (rtl_dump_file)
! 		fprintf (rtl_dump_file,
! 			 "Outcomes of branch in bb %i and %i differs to much (%i %i)\n",
! 			 bb1->index, bb2->index, b1->probability, prob2);
! 
! 	      return false;
! 	    }
  	}
  
        if (rtl_dump_file && match)
Index: tracer.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Attic/tracer.c,v
retrieving revision 1.1.2.15
diff -c -3 -p -r1.1.2.15 tracer.c
*** tracer.c	2001/12/20 21:15:06	1.1.2.15
--- tracer.c	2001/12/31 14:32:37
*************** static bool ignore_bb_p			PARAMS ((basic
*** 58,73 ****
     important.  They are just meant to rule out cold regions of code
     that are usually easy to recognize.  */
  
- /* When profile feedback is available, do not trace blocks with fewer
-    executions than this constant.  */
- 
- #define MIN_COUNT	100
- 
- /* Trace only blocks executed maximally 1000 times fewer times than the
-    most frequent block in the function.  */
- 
- #define MIN_FREQUENCY  BB_FREQ_MAX/1000
- 
  /* Stop tracing after at least 95% of instructions has been convered
     by constructed superblocks.  */
  
--- 58,63 ----
*************** static bool ignore_bb_p			PARAMS ((basic
*** 80,89 ****
  
  #define MAXIMAL_CODE_GROWTH 2.0
  
! /* Stop growth if the best edge probability is less than
!    this threshold (ie there are many edges with small probabilities).  */
  #define MIN_BRANCH_RATIO 0.1
  
  /* Return true if BB has been seen - it is connected to some trace
     already.  */
  
--- 70,92 ----
  
  #define MAXIMAL_CODE_GROWTH 2.0
  
! /* Stop reverse growth if the reverse probability of best edge is less than
!    this threshold (ie there are many predecessors with small probabilities).  */
! 
  #define MIN_BRANCH_RATIO 0.1
  
+ /* Stop forward growth if the best edge do have probability lower than this
+    threshold.  For statically estimated profiles the probabilities do have
+    different meaning than for measured profiles.  Low probability for estimated
+    profile signalized that compiler is uncertain about the branch outcome, while
+    low probability from profile feedback signals badly predictable branch.
+ 
+    We do not want to trace in both cases, as tracing in wrong direction is
+    wastefull and overactive tracing of badly predictable jumps interfere
+    badly with if converison pass.  The thresholds needs to be different.  */
+ 
+ #define MIN_BRANCH_PROBABILITY (flag_branch_probabilities ? 0.8 : 0.7)
+ 
  /* Return true if BB has been seen - it is connected to some trace
     already.  */
  
*************** find_best_successor (basic_block bb)
*** 146,152 ****
        best = e;
    if (!best || ignore_bb_p (best->dest))
      return NULL;
!   if (best->probability < (int)(REG_BR_PROB_BASE * MIN_BRANCH_RATIO))
      return NULL;
    return best;
  }
--- 149,155 ----
        best = e;
    if (!best || ignore_bb_p (best->dest))
      return NULL;
!   if (best->probability < (int)(REG_BR_PROB_BASE * MIN_BRANCH_PROBABILITY))
      return NULL;
    return best;
  }


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