public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] division bugfix
@ 2023-04-18 19:47 Ondrej Kubanek
  0 siblings, 0 replies; only message in thread
From: Ondrej Kubanek @ 2023-04-18 19:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:39612a0f227ba2df1145fa7a08655f296ba2335b

commit 39612a0f227ba2df1145fa7a08655f296ba2335b
Author: kubaneko <kubanek0ondrej@gmail.com>
Date:   Tue Apr 18 15:36:45 2023 +0000

    division bugfix

Diff:
---
 gcc/cfgloop.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc
index 0a8727e9a97..c8a010ca08b 100644
--- a/gcc/cfgloop.cc
+++ b/gcc/cfgloop.cc
@@ -2308,7 +2308,8 @@ histogram_counters_div_upper_bound (histogram_counters *&hist_c,
   unsigned int i = 1;
   for (; i < lin_size && i < tot_size - 1; i++)
     {
-      hist[i / divisor] += hist[i];
+      // we want to take the roof of the division
+      hist[i / divisor + MIN (1, i % divisor)] += hist[i];
       hist[i] = 0;
     }
 
@@ -2318,7 +2319,8 @@ histogram_counters_div_upper_bound (histogram_counters *&hist_c,
 	= ((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 is allways different then i since we know divisor>1
+      hist[ind] += hist[MIN (1, i)];
       hist[i] = 0;
     }
 }

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

only message in thread, other threads:[~2023-04-18 19:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 19:47 [gcc(refs/users/kubaneko/heads/histogram)] division bugfix 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).