From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id E170F385800A; Thu, 16 Feb 2023 16:28:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E170F385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676564936; bh=BKqIh/hXCBaJ2XVAEAi78TrUMYa1ICxUyDfZuIf+uMc=; h=From:To:Subject:Date:From; b=uXkYWeWCUqxNJTQXfJdjCQM+0ulgiRGMQAgrq2SzB24XVPoHMwIQK21wVFGO5cKn9 sshJv1sHd+Qx5xxPl/d8ExDNrLASSaWu9AEG01cD3qn3esdwOtDmgD8TUTmrUgG4PY FcJoHkuE5fFOa3zZHtPZQf2YOVoHSnjEpstYaZeU= 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)] added primitive histogram peeling X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: 18009000aa840b2c6d759334ab28a0e9fc07128d X-Git-Newrev: 4427e303ae942377207924364a3444ce9835b9cf Message-Id: <20230216162856.E170F385800A@sourceware.org> Date: Thu, 16 Feb 2023 16:28:56 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4427e303ae942377207924364a3444ce9835b9cf commit 4427e303ae942377207924364a3444ce9835b9cf Author: kubaneko Date: Sun Feb 12 21:33:50 2023 +0000 added primitive histogram peeling Diff: --- gcc/tree-ssa-loop-ivcanon.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc index c36efe28dc2..9858d11fcd9 100644 --- a/gcc/tree-ssa-loop-ivcanon.cc +++ b/gcc/tree-ssa-loop-ivcanon.cc @@ -1037,20 +1037,20 @@ 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; + for (int i=0;icounters->hist))[i]; + if ((100*psum)/sum>=90) + { + npeel=i; + continue; + } + } + } if (npeel < 0) npeel = likely_max_loop_iterations_int (loop);