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 tweek



Hi,
this patch avoids construction of dumb traces when many edges are present.
This is the case of join block after switch and similar beasts.

Honza

Wed Dec 12 16:19:17 CET 2001  Jan Hubicka  <jh@suse.cz>

	* tracer.c (DYNAMIC_COVERAGE, MAXIMAL_CODE_GROWTH): Use floating point
	value to hold ratio.
	(MIN_BRANCH_RATIO): New constant.
	(find_best_successor, find_best_predecessor): Use it.
	(tail_duplicate): Rescale floats to integers.

Index: tracer.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/Attic/tracer.c,v
retrieving revision 1.1.2.13
diff -c -3 -p -r1.1.2.13 tracer.c
*** tracer.c	2001/11/22 16:32:49	1.1.2.13
--- tracer.c	2001/12/12 15:19:07
*************** static bool ignore_bb_p			PARAMS ((basic
*** 68,85 ****
  
  #define MIN_FREQUENCY  BB_FREQ_MAX/1000
  
! /* Stop tracing after at least 80% of instructions has been convered
     by constructed superblocks.  */
  
! #define DYNAMIC_COVERAGE 95
  
  /* Stop once the number of instructions has been increased to 200%.
     This is rather hokey argument, as most of the duplicates will be elliminated
     later in cross jumping, but we need to keep the code size and compiler
     resource usage under control.  */
  
! #define MAXIMAL_CODE_GROWTH 200
  
  /* Return true if BB has been seen - it is connected to some trace
     already.  */
  
--- 68,89 ----
  
  #define MIN_FREQUENCY  BB_FREQ_MAX/1000
  
! /* Stop tracing after at least 95% of instructions has been convered
     by constructed superblocks.  */
  
! #define DYNAMIC_COVERAGE 0.95
  
  /* Stop once the number of instructions has been increased to 200%.
     This is rather hokey argument, as most of the duplicates will be elliminated
     later in cross jumping, but we need to keep the code size and compiler
     resource usage under control.  */
  
! #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.  */
  
*************** find_best_successor (basic_block bb)
*** 145,150 ****
--- 149,156 ----
        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;
  }
  
*************** find_best_predecessor (basic_block bb)
*** 161,166 ****
--- 167,175 ----
        best = e;
    if (!best || ignore_bb_p (best->src))
      return NULL;
+   if (EDGE_FREQUENCY (best) * REG_BR_PROB_BASE
+       < bb->frequency * (int)(REG_BR_PROB_BASE * MIN_BRANCH_RATIO))
+     return NULL;
    return best;
  }
  
*************** tail_duplicate ()
*** 236,243 ****
        weighted_insns += n * BASIC_BLOCK (i)->frequency;
      }
  
!   for (; traced_insns * 100 < weighted_insns * DYNAMIC_COVERAGE
! 	 && (nduplicated + ninsns) * 100 < ninsns * MAXIMAL_CODE_GROWTH
  	 && !fibheap_empty (heap);)
      {
        basic_block bb = fibheap_extract_min (heap);
--- 245,253 ----
        weighted_insns += n * BASIC_BLOCK (i)->frequency;
      }
  
!   for (; traced_insns * 100 < weighted_insns * (int) (DYNAMIC_COVERAGE * 100)
! 	 && ((nduplicated + ninsns) * 100
! 	     < ninsns * (int )(100 * MAXIMAL_CODE_GROWTH))
  	 && !fibheap_empty (heap);)
      {
        basic_block bb = fibheap_extract_min (heap);


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