From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 10A723858D33; Wed, 15 Mar 2023 00:21:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 10A723858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678839718; bh=QxPdt9pEtOJwu9G1xIzWhkq8IKg0zE45SyvfADmIiqE=; h=From:To:Subject:Date:From; b=skD2X0TnwFt832Z9GyXCfbFGZdtSa/oizaZMZ3qbVbi6yZBnX5P7e1ApDUc0QNsVl g9Spi/RAudDzcXhgHRCCwXHiYNgT7tbY4sDKoj5yxtS9MQ+kWqXGPsoJtKS0MZjQgk 2eH0fiDqSi0xDv4taHGdKc0KjYtjabHexv31VMzI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ondrej Kubanek To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] fixed up fix-up functions X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: 03453fc0062d949f1e7f99618c3be23a626b1088 X-Git-Newrev: b9d5d2a699fe0ebf877abfcab3284b901f790091 Message-Id: <20230315002158.10A723858D33@sourceware.org> Date: Wed, 15 Mar 2023 00:21:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b9d5d2a699fe0ebf877abfcab3284b901f790091 commit b9d5d2a699fe0ebf877abfcab3284b901f790091 Author: kubaneko Date: Wed Mar 15 00:21:44 2023 +0000 fixed up fix-up functions Diff: --- gcc/cfgloop.cc | 69 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc index f5e229e18c1..d23ee01bea7 100644 --- a/gcc/cfgloop.cc +++ b/gcc/cfgloop.cc @@ -2185,16 +2185,35 @@ loops_list::walk_loop_tree (class loop *root, unsigned flags) this->to_visit.quick_push (root->num); } +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 (valpow2){ + return pow2+(lin_size-lin_pow2)-1; + } else { + return tot_size-1; + } + } +} + void histogram_counters_minus_upper_bound (histogram_counters* hist_c, gcov_type_unsigned difference){ - if (hist_c==NULL || difference==0) + if (!hist_c || difference==0) return; auto hist=*(hist_c->hist); unsigned int lin_size=param_profile_histogram_size_lin; - unsigned int lin_pow2=floor_log2(lin_size-1); unsigned int tot_size=param_profile_histogram_size; - gcov_type_unsigned log_diff=floor_log2(difference); + + // next power of 2 for linear hist + unsigned int lin_size_upp=1<2 && difference>1) + (pow2 >> 2); + int64_t diff=hist[i]/2; + unsigned int ind=hist_index(half>=difference?half-difference:0); + if (ind==i) + return; + hist[ind]+=diff; + hist[i]-=diff; + pow2<<=1; } }