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]

Re: RFA: estimate probabilities if profile information not available


> > !     count_max = MAX (bb->count, true_count_max);
> 
>        ^^^
> Surely a typo?

Oops, yes, and a particularily nasty one.

> > !   if (! flag_branch_probabilities || ! counts_to_freqs ())
> 
> codingconventions.html sez "!x", not "! x".

Hmm, it does say so now.  Not that you could tell from the code base yet:

bash-2.05$ cat *.c | grep -c '![a-zA-Z]' 
2940
bash-2.05$ cat *.c | grep -c '! [a-zA-Z]' 
2965

Appended is the fixed patch.
bootstrapped on i686-pc-linux-gnu

2004-01-27  J"orn Rennecke <joern.rennecke@superh.com>

	* coverage.c (get_coverage_counts): Give a different message
	if flag_guess_branch_prob is set.
	* predict.c (counts_to_freqs): Return an int.
	(estimate_bb_frequencies): If counts_to_freqs returns zero,
	calculate estimates.

Index: coverage.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/coverage.c,v
retrieving revision 1.28
diff -p -r1.28 coverage.c
*** coverage.c	18 Jan 2004 15:10:23 -0000	1.28
--- coverage.c	27 Jan 2004 14:43:20 -0000
*************** get_coverage_counts (unsigned counter, u
*** 316,322 ****
        static int warned = 0;
  
        if (!warned++)
! 	inform ("file %s not found, execution counts assumed to be zero",
  		da_file_name);
        return NULL;
      }
--- 316,324 ----
        static int warned = 0;
  
        if (!warned++)
! 	inform ((flag_guess_branch_prob
! 		 ? "file %s not found, execution counts estimated"
! 		 : "file %s not found, execution counts assumed to be zero"),
  		da_file_name);
        return NULL;
      }
Index: predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.98
diff -p -r1.98 predict.c
*** predict.c	16 Jan 2004 01:44:06 -0000	1.98
--- predict.c	27 Jan 2004 14:43:20 -0000
*************** static void dump_prediction (enum br_pre
*** 71,77 ****
  static void estimate_loops_at_level (struct loop *loop);
  static void propagate_freq (struct loop *);
  static void estimate_bb_frequencies (struct loops *);
! static void counts_to_freqs (void);
  static void process_note_predictions (basic_block, int *);
  static void process_note_prediction (basic_block, int *, int, int);
  static bool last_basic_block_p (basic_block);
--- 71,77 ----
  static void estimate_loops_at_level (struct loop *loop);
  static void propagate_freq (struct loop *);
  static void estimate_bb_frequencies (struct loops *);
! static int counts_to_freqs (void);
  static void process_note_predictions (basic_block, int *);
  static void process_note_prediction (basic_block, int *, int, int);
  static bool last_basic_block_p (basic_block);
*************** estimate_loops_at_level (struct loop *fi
*** 1048,1066 ****
      }
  }
  
! /* Convert counts measured by profile driven feedback to frequencies.  */
  
! static void
  counts_to_freqs (void)
  {
!   gcov_type count_max = 1;
    basic_block bb;
  
    FOR_EACH_BB (bb)
!     count_max = MAX (bb->count, count_max);
  
    FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
      bb->frequency = (bb->count * BB_FREQ_MAX + count_max / 2) / count_max;
  }
  
  /* Return true if function is likely to be expensive, so there is no point to
--- 1048,1069 ----
      }
  }
  
! /* Convert counts measured by profile driven feedback to frequencies.
!    Return nonzero iff there was any nonzero execution count.  */
  
! static int
  counts_to_freqs (void)
  {
!   gcov_type count_max, true_count_max = 0;
    basic_block bb;
  
    FOR_EACH_BB (bb)
!     true_count_max = MAX (bb->count, true_count_max);
  
+   count_max = MAX (true_count_max, 1);
    FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
      bb->frequency = (bb->count * BB_FREQ_MAX + count_max / 2) / count_max;
+   return true_count_max;
  }
  
  /* Return true if function is likely to be expensive, so there is no point to
*************** estimate_bb_frequencies (struct loops *l
*** 1113,1121 ****
    basic_block bb;
    sreal freq_max;
  
!   if (flag_branch_probabilities)
!     counts_to_freqs ();
!   else
      {
        static int real_values_initialized = 0;
  
--- 1116,1122 ----
    basic_block bb;
    sreal freq_max;
  
!   if (!flag_branch_probabilities || !counts_to_freqs ())
      {
        static int real_values_initialized = 0;
  


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