[gcc(refs/users/kubaneko/heads/histogram)] added primitive peeling and stuff
Ondrej Kubanek
kubaneko@gcc.gnu.org
Thu Feb 23 18:38:11 GMT 2023
https://gcc.gnu.org/g:4bcaa73f688cbd2dc330e60a36cbf4dc8c9537a8
commit 4bcaa73f688cbd2dc330e60a36cbf4dc8c9537a8
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Thu Feb 23 17:04:31 2023 +0000
added primitive peeling and stuff
Diff:
---
gcc/cfgloop.h | 2 +-
gcc/tree-profile.cc | 7 +++++--
gcc/tree-ssa-loop-ivcanon.cc | 30 ++++++++++++++++--------------
3 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index 0ee603893e7..187edd30b31 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -297,7 +297,7 @@ public:
reused. */
basic_block former_header;
- histogram_counters* counters=NULL;
+ histogram_counters* counters;
};
/* Set if the loop is known to be infinite. */
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 95f1f70fd7c..6f4f3712246 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -170,7 +170,7 @@ gimple_init_gcov_profiler (void)
/* void (*) (gcov_type *, gcov_type) */
histogram_profiler_fn_type
= build_function_type_list (void_type_node,
- gcov_type_ptr, gcov_type_node,
+ gcov_type_ptr, gcov_type_node, gcov_type_node,
NULL_TREE);
fn_name = concat ("__gcov_histogram_profiler", fn_suffix, NULL);
tree_histogram_profiler_fn = build_fn_decl (fn_name, histogram_profiler_fn_type);
@@ -364,11 +364,14 @@ gimple_gen_histogram_profiler (histogram_value value, unsigned tag) // , edge_de
auto lp = value->hvalue.lp;
gcc_assert(lp);
tree ref_ptr = tree_coverage_counter_addr (tag, 0);
+ tree hist_size = build_int_cst_type (gcov_type_node,
+ param_profile_histogram_size_lin + (gcov_type(param_profile_histogram_size)<<32));
gcall *call;
auto_vec<edge> exits = get_loop_exit_edges (lp);
for ( auto exit : exits ){
if (!(exit->flags & (EDGE_COMPLEX | EDGE_FAKE))) {
- call = gimple_build_call (tree_histogram_profiler_fn, 2, ref_ptr, value->hvalue.value);
+ call = gimple_build_call (tree_histogram_profiler_fn, 3, ref_ptr,
+ value->hvalue.value, hist_size);
gsi_insert_seq_on_edge (exit, call);
}
}
diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc
index c36efe28dc2..be489f3197e 100644
--- a/gcc/tree-ssa-loop-ivcanon.cc
+++ b/gcc/tree-ssa-loop-ivcanon.cc
@@ -1037,20 +1037,22 @@ try_peel_loop (class loop *loop,
npeel = estimated_loop_iterations_int (loop);
// linear part most common number
- //bool histogram_peeling=loop->counters!=NULL;
- //if (histogram_peeling){
- // gcov_type max=0;
- // int most_common=-1;
- // for (int i=0;i<8; i++){
- // if (loop->counters->hist[i]>=max){
- // most_common=i;
- // }
- // }
- // if (most_common>0)
- // {
- // npeel=most_common+1;
- // }
- //}
+ // peels if in linear portion there is more then 90% of iterations
+ bool histogram_peeling=loop->counters!=NULL;
+ if (histogram_peeling){
+ gcov_type psum=0;
+ gcov_type sum=loop->counters->sum;
+ if (sum!=0){
+ for (int i=0;i<param_profile_histogram_size_lin; i++){
+ psum+=(*(loop->counters->hist))[i];
+ if ((100*psum)/sum>=90)
+ {
+ npeel=i;
+ continue;
+ }
+ }
+ }
+ }
if (npeel < 0)
npeel = likely_max_loop_iterations_int (loop);
More information about the Gcc-cvs
mailing list