[gcc(refs/users/kubaneko/heads/histogram)] fixed error and improved peeling
Ondrej Kubanek
kubaneko@gcc.gnu.org
Tue Mar 7 20:09:26 GMT 2023
https://gcc.gnu.org/g:67511ca09d839376168f48582b1c41f0228c29e6
commit 67511ca09d839376168f48582b1c41f0228c29e6
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Wed Mar 1 20:30:09 2023 +0000
fixed error and improved peeling
Diff:
---
gcc/params.opt | 4 ++++
gcc/tree-ssa-loop-ivcanon.cc | 11 ++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gcc/params.opt b/gcc/params.opt
index 804c5cdbe76..ee21ee7d941 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -882,6 +882,10 @@ Total size of the histogram counter for profile feedback.
Common Joined UInteger Var(param_profile_histogram_size_lin) Init(8) Param Optimization
Size of the linear portion of the histogram counter for profile feedback.
+-param=profile-histogram-peel-prcnt=
+Common Joined UInteger Var(param_profile_histogram_peel_prcnt) Init(90) Param Optimization
+Peeles if can eliminate at least this percentage of iterations.
+
-param=profile-func-internal-id=
Common Joined UInteger Var(param_profile_func_internal_id) IntegerRange(0, 1) Param
Use internal function id in profile lookup.
diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc
index 38f947f9e8a..7ef2a3e2525 100644
--- a/gcc/tree-ssa-loop-ivcanon.cc
+++ b/gcc/tree-ssa-loop-ivcanon.cc
@@ -1045,10 +1045,15 @@ try_peel_loop (class loop *loop,
if (sum!=0){
for (int i=0;i<param_profile_histogram_size_lin; i++){
psum+=(*(loop->counters->hist))[i];
- if ((100*psum)/sum>=90)
+ if ((100*psum)/sum>=param_profile_histogram_peel_prcnt)
{
- npeel=i;
- continue;
+ if (i==param_profile_histogram_size_lin-1 && i!=0){
+ // Last linear counter absorbs iterations smaller then next power of 2
+ npeel=(1<<floor_log2(param_profile_histogram_size_lin-1))-1;
+ } else {
+ npeel=i;
+ }
+ break;
}
}
}
More information about the Gcc-cvs
mailing list