public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] fixed error and improved peeling
@ 2023-03-07 20:09 Ondrej Kubanek
  0 siblings, 0 replies; only message in thread
From: Ondrej Kubanek @ 2023-03-07 20:09 UTC (permalink / raw)
  To: gcc-cvs

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;
         }
     }
     }

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

only message in thread, other threads:[~2023-03-07 20:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 20:09 [gcc(refs/users/kubaneko/heads/histogram)] fixed error and improved peeling 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).