From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 23DDF3858D32; Sun, 12 Feb 2023 21:36:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23DDF3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676237791; bh=3u50a2vKULHn8T4ueRgj7+95qeHnyQPVPeEQl0eAVkI=; h=From:To:Subject:Date:From; b=dykt0Xsr5aet7X7PlhMnjoUoQqn7oTLfF+ssuBIa7rWT0yPSuN5V4rjJi9jxpT1L2 gej24sB+r1gkuU98HZd47YxY2BzL5fPft1POYqll5o/yLvdUTyGjUVsig6DUWrHQDM X2ueMkz9WPq1W5nwqAnVOS38KdcbW4eAT/G1Btaw= 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: d389e3e2bc71aea126b27eeaedc6b114d9222660 X-Git-Newrev: 91082983c3f2f06ffa39814b6b4ca1c2dcc249c1 Message-Id: <20230212213631.23DDF3858D32@sourceware.org> Date: Sun, 12 Feb 2023 21:36:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:91082983c3f2f06ffa39814b6b4ca1c2dcc249c1 commit 91082983c3f2f06ffa39814b6b4ca1c2dcc249c1 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);