From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 13B8C385841A; Tue, 14 Mar 2023 17:23:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13B8C385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678814590; bh=XrPTgIfc+6kx4d7hfBBgjF5/N/nn08aYi6i0L2wUwNI=; h=From:To:Subject:Date:From; b=ZIDy2e1tuyuhRWFqxrLXHkgbU3y5kvXfg5QpkbMnWYFPq5f40NbWeKVuE1SRuk2is vWJ/TWwbfQv3kI06Ng49VVpyystssIt9q5a80g2LvY+35JwRh5xrvUl/edlZfSdzm/ 5bOG7cgDIzEf5R4WQTQf5LP94ufGpdCfFB/RB4kg= 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)] some refactoring and added lto-streaming for histograms X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: 18ffdd8c9ae664bf186de31febebf9bc5c78ec27 X-Git-Newrev: e755feaf21fe3b58357ac90440e67733a032db47 Message-Id: <20230314172310.13B8C385841A@sourceware.org> Date: Tue, 14 Mar 2023 17:23:10 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e755feaf21fe3b58357ac90440e67733a032db47 commit e755feaf21fe3b58357ac90440e67733a032db47 Author: kubaneko Date: Mon Mar 13 21:31:03 2023 +0000 some refactoring and added lto-streaming for histograms Diff: --- gcc/cfgloop.h | 73 ------------------------------------------------- gcc/lto-streamer-in.cc | 11 ++++++++ gcc/lto-streamer-out.cc | 7 +++++ gcc/tree-vect-loop.cc | 9 ++---- 4 files changed, 20 insertions(+), 80 deletions(-) diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 48badc22648..6a7ef44b8e1 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -99,79 +99,6 @@ struct GTY(()) histogram_counters{ vec * GTY((skip)) hist; }; -// void histogram_counters_minus_upper_bound (histogram_counters* hist_c, gcov_type_unsigned difference){ -// if (hist_c==NULL || 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); -// unsigned int i=1; -// for(; i2 && differencehist); -// 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(; i1){ -// 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; -// } -// } -// } - typedef class loop *loop_p; /* An integer estimation of the number of iterations. Estimate_state diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc index 03cb41cfa16..2cf59858a54 100644 --- a/gcc/lto-streamer-in.cc +++ b/gcc/lto-streamer-in.cc @@ -1126,6 +1126,17 @@ input_cfg (class lto_input_block *ib, class data_in *data_in, loop->any_estimate = streamer_read_hwi (ib); if (loop->any_estimate) loop->nb_iterations_estimate = streamer_read_widest_int (ib); + // whether the loop has histogram counter + if (streamer_read_hwi (ib)){ + loop->counters=ggc_alloc(); + loop->counters->sum=streamer_read_gcov_count (ib); + loop->counters->hist=NULL; + vec_safe_grow_cleared(loop->counters->hist,param_profile_histogram_size); + for (int i=0;icounters->hist)[i]=streamer_read_gcov_count (ib); + } + } + /* Read OMP SIMD related info. */ loop->safelen = streamer_read_hwi (ib); diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc index 0bca530313c..8901a82dd67 100644 --- a/gcc/lto-streamer-out.cc +++ b/gcc/lto-streamer-out.cc @@ -2181,6 +2181,13 @@ output_cfg (struct output_block *ob, struct function *fn) streamer_write_hwi (ob, loop->any_estimate); if (loop->any_estimate) streamer_write_widest_int (ob, loop->nb_iterations_estimate); + streamer_write_hwi (ob, loop->counters!=NULL); + if (loop->counters) { + streamer_write_gcov_count (ob, loop->counters->sum); + for (unsigned int i=0; icounters->hist)[i]); + } + } /* Write OMP SIMD related info. */ streamer_write_hwi (ob, loop->safelen); diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 74622aef0f9..cc2ed78b52e 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -11067,13 +11067,8 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) lowest_vf) - 1 : wi::udiv_floor (loop->nb_iterations_upper_bound + bias_for_lowest, lowest_vf) - 1); - if (final_iter_may_be_partial){ - histogram_counters_div_upper_bound(loop->counters,lowest_vf); - histogram_counters_minus_upper_bound(loop->counters,1); - } else { - histogram_counters_div_upper_bound(loop->counters,lowest_vf); - histogram_counters_minus_upper_bound(loop->counters,1); - } + histogram_counters_div_upper_bound(loop->counters,lowest_vf); + histogram_counters_minus_upper_bound(loop->counters,1); if (main_vinfo /* Both peeling for alignment and peeling for gaps can end up with the scalar epilogue running for more than VF-1 iterations. */