public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] some minor divise fixes
@ 2023-03-15  8:16 Ondrej Kubanek
  0 siblings, 0 replies; only message in thread
From: Ondrej Kubanek @ 2023-03-15  8:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9d883347fd7f4433965b7b2384b453bdb17a0f5a

commit 9d883347fd7f4433965b7b2384b453bdb17a0f5a
Author: kubaneko <kubanek0ondrej@gmail.com>
Date:   Wed Mar 15 08:16:04 2023 +0000

    some minor divise fixes

Diff:
---
 gcc/cfgloop.cc | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc
index d23ee01bea7..6b4412568d1 100644
--- a/gcc/cfgloop.cc
+++ b/gcc/cfgloop.cc
@@ -2249,7 +2249,6 @@ void histogram_counters_div_upper_bound (histogram_counters* hist_c, unsigned in
     auto hist=*(hist_c->hist);
     unsigned int lin_size=param_profile_histogram_size_lin;
     unsigned int tot_size=param_profile_histogram_size;
-    gcov_type_unsigned  log_div=floor_log2(divisor);
     unsigned int i=1;
     for(; i<lin_size-1 && i<tot_size-1; i++){
         hist[i/divisor]+=hist[i];
@@ -2257,13 +2256,10 @@ void histogram_counters_div_upper_bound (histogram_counters* hist_c, unsigned in
     }
 
     for (;i<tot_size-1;i++){
-        gcov_type_unsigned upper_diff=((1<<(ceil_log2(lin_size)+i-lin_size))-1)/divisor;
-        if (upper_diff<lin_size-1 && lin_size>1){
-            hist[upper_diff==0 ? 1 : upper_diff]+=hist[i];
-            hist[i]=0;
-        } else {
-            hist[i-log_div>0?i-log_div : 1]+=hist[i];
-            hist[i]=0;
-        }
+        gcov_type_unsigned upper_pow2=((gcov_type_unsigned)1)<<(ceil_log2(lin_size)+i+1-lin_size);
+        gcov_type_unsigned half=(upper_pow2>>2)+(upper_pow2>>1);
+        unsigned int ind=hist_index(half/divisor);
+        hist[ind]+=hist[i];
+        hist[i]=0;
     }
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-15  8:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  8:16 [gcc(refs/users/kubaneko/heads/histogram)] some minor divise fixes 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).