public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ondrej Kubanek <kubaneko@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] changed where iterations between linear portion and the next pow2 go Date: Mon, 27 Mar 2023 16:00:05 +0000 (GMT) [thread overview] Message-ID: <20230327160005.C5AAC3858426@sourceware.org> (raw) 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]++; - } + }} } }
reply other threads:[~2023-03-27 16:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230327160005.C5AAC3858426@sourceware.org \ --to=kubaneko@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).