public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] changed where iterations between linear portion and the next pow2 go
@ 2023-03-27 16:00 Ondrej Kubanek
0 siblings, 0 replies; only message in thread
From: Ondrej Kubanek @ 2023-03-27 16:00 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c69efdb5f4066002938f70b9f9220af488473761
commit c69efdb5f4066002938f70b9f9220af488473761
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Mon Mar 27 15:59:53 2023 +0000
changed where iterations between linear portion and the next pow2 go
Diff:
---
gcc/cfgloop.cc | 43 ++++++++++++++++++++++++-------------------
libgcc/libgcov-profiler.c | 6 ++++--
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc
index 6b4412568d1..3c66e7962c6 100644
--- a/gcc/cfgloop.cc
+++ b/gcc/cfgloop.cc
@@ -2186,19 +2186,28 @@ loops_list::walk_loop_tree (class loop *root, unsigned flags)
}
unsigned int hist_index(gcov_type_unsigned val){
- unsigned int lin_size=param_profile_histogram_size_lin;
- unsigned int tot_size=param_profile_histogram_size;
- if (val<lin_size){
- return val;
- }else{
- gcov_type_unsigned pow2=floor_log2(val);
- gcov_type_unsigned lin_pow2=floor_log2(lin_size-1);
- if ((lin_pow2-lin_size)+tot_size>pow2){
- return pow2+(lin_size-lin_pow2)-1;
- } else {
- return tot_size-1;
- }
- }
+ unsigned int lin_size = param_profile_histogram_size_lin;
+ unsigned int tot_size = param_profile_histogram_size;
+ if (val < lin_size)
+ {
+ return val;
+ }
+ else
+ {
+ gcov_type_unsigned pow2 = floor_log2 (val);
+ gcov_type_unsigned lin_pow2 = floor_log2 (lin_size - 1);
+ if (lin_size<tot_size && pow2==lin_pow2){
+ return lin_size;
+ }
+ if (tot_size > pow2 + ((lin_size - 1) - lin_pow2))
+ {
+ return pow2 + ((lin_size - 1)- lin_pow2);
+ }
+ else
+ {
+ return tot_size - 1;
+ }
+ }
}
void histogram_counters_minus_upper_bound (histogram_counters* hist_c, gcov_type_unsigned difference){
@@ -2207,13 +2216,9 @@ void histogram_counters_minus_upper_bound (histogram_counters* hist_c, gcov_type
auto hist=*(hist_c->hist);
unsigned int lin_size=param_profile_histogram_size_lin;
unsigned int tot_size=param_profile_histogram_size;
-
- // next power of 2 for linear hist
- unsigned int lin_size_upp=1<<ceil_log2(lin_size);
// If the last linear counter does not contain other iterations
- unsigned int last_lin=(lin_size_upp==lin_size?0:1);
unsigned int i=1;
- for(; i<lin_size-last_lin; i++){
+ for(; i<lin_size; i++){
if (i<=difference){
hist[0]+=hist[i];
} else {
@@ -2250,7 +2255,7 @@ void histogram_counters_div_upper_bound (histogram_counters* hist_c, unsigned in
unsigned int lin_size=param_profile_histogram_size_lin;
unsigned int tot_size=param_profile_histogram_size;
unsigned int i=1;
- for(; i<lin_size-1 && i<tot_size-1; i++){
+ for(; i<lin_size && i<tot_size-1; i++){
hist[i/divisor]+=hist[i];
hist[i]=0;
}
diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c
index 7d9ff90d40c..5c73fb98abc 100644
--- a/libgcc/libgcov-profiler.c
+++ b/libgcc/libgcov-profiler.c
@@ -74,11 +74,13 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value, gcov_type hist_
}else{
gcov_type_unsigned pow2=floor_log2(u_value);
gcov_type_unsigned lin_pow2=floor_log2(lin_size-1);
- if ((lin_pow2-lin_size)+tot_size>pow2){
+ if (lin_size<tot_size && pow2==lin_pow2){
+ counters[lin_size]++;
+ } else { if ((lin_pow2-lin_size)+tot_size>pow2){
counters[pow2+(lin_size-lin_pow2)-1]++;
} else {
counters[tot_size-1]++;
- }
+ }}
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-27 16:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 16:00 [gcc(refs/users/kubaneko/heads/histogram)] changed where iterations between linear portion and the next pow2 go Ondrej Kubanek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).