From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23001 invoked by alias); 9 Jun 2017 14:04:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 22977 invoked by uid 89); 9 Jun 2017 14:04:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=scanned X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Jun 2017 14:04:20 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 882E1548009; Fri, 9 Jun 2017 16:04:22 +0200 (CEST) Date: Fri, 09 Jun 2017 14:04:00 -0000 From: Jan Hubicka To: marxin Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 3/3] Rework cold and hot label attributes in predict.c. Message-ID: <20170609140422.GH53583@kam.mff.cuni.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2017-06/txt/msg00653.txt.bz2 > gcc/ChangeLog: > > 2017-05-26 Martin Liska > > * gimplify.c (gimplify_label_expr): Insert GIMPLE_PREDICT > statements on cold and hot labels. > * predict.c (tree_estimate_probability_bb): Remove the > prediction from this place. > > gcc/testsuite/ChangeLog: > > 2017-05-31 Martin Liska > > * gcc.dg/tree-ssa/attr-hotcold-2.c: Update scanned patterns. OK, thanks! Honza > --- > gcc/gimplify.c | 10 +++++++++- > gcc/predict.c | 23 ----------------------- > > gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c | 4 ++-- > 3 files changed, 11 insertions(+), 26 deletions(-) > > diff --git a/gcc/gimplify.c b/gcc/gimplify.c > index f192a891a8c..b2818e2465f 100644 > --- a/gcc/gimplify.c > +++ b/gcc/gimplify.c > @@ -2356,10 +2356,18 @@ gimplify_label_expr (tree *expr_p, gimple_seq *pre_p) > gcc_assert (decl_function_context (LABEL_EXPR_LABEL (*expr_p)) > == current_function_decl); > > - glabel *label_stmt = gimple_build_label (LABEL_EXPR_LABEL (*expr_p)); > + tree label = LABEL_EXPR_LABEL (*expr_p); > + glabel *label_stmt = gimple_build_label (label); > gimple_set_location (label_stmt, EXPR_LOCATION (*expr_p)); > gimplify_seq_add_stmt (pre_p, label_stmt); > > + if (lookup_attribute ("cold", DECL_ATTRIBUTES (label))) > + gimple_seq_add_stmt (pre_p, gimple_build_predict (PRED_COLD_LABEL, > + NOT_TAKEN)); > + else if (lookup_attribute ("hot", DECL_ATTRIBUTES (label))) > + gimple_seq_add_stmt (pre_p, gimple_build_predict (PRED_HOT_LABEL, > + TAKEN)); > + > return GS_ALL_DONE; > } > > diff --git a/gcc/predict.c b/gcc/predict.c > index d561f27342d..419a4842f03 100644 > --- a/gcc/predict.c > +++ b/gcc/predict.c > @@ -2698,29 +2698,6 @@ tree_estimate_probability_bb (basic_block bb) > > FOR_EACH_EDGE (e, ei, bb->succs) > { > - /* Predict edges to user labels with attributes. */ > - if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)) > - { > - gimple_stmt_iterator gi; > - for (gi = gsi_start_bb (e->dest); !gsi_end_p (gi); gsi_next (&gi)) > - { > - glabel *label_stmt = dyn_cast (gsi_stmt (gi)); > - tree decl; > - > - if (!label_stmt) > - break; > - decl = gimple_label_label (label_stmt); > - if (DECL_ARTIFICIAL (decl)) > - continue; > - > - /* Finally, we have a user-defined label. */ > - if (lookup_attribute ("cold", DECL_ATTRIBUTES (decl))) > - predict_edge_def (e, PRED_COLD_LABEL, NOT_TAKEN); > - else if (lookup_attribute ("hot", DECL_ATTRIBUTES (decl))) > - predict_edge_def (e, PRED_HOT_LABEL, TAKEN); > - } > - } > - > /* Look for block we are guarding (ie we dominate it, > but it doesn't postdominate us). */ > if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && e->dest != bb > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c > index 13d2916c47b..184dd10ddae 100644 > --- a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c > +++ b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c > @@ -20,9 +20,9 @@ void f(int x, int y) > > /* { dg-final { scan-tree-dump-times "hot label heuristics" 1 "profile_estimate" } } */ > /* { dg-final { scan-tree-dump-times "cold label heuristics" 1 "profile_estimate" } } */ > -/* { dg-final { scan-tree-dump-times "block 4, loop depth 0, count 0, freq \[1-4\]\[^0-9\]" 3 "profile_estimate" } } */ > +/* { dg-final { scan-tree-dump "A \\\[0\\\..*\\\]" "profile_estimate" } } */ > > /* Note: we're attempting to match some number > 6000, i.e. > 60%. > The exact number ought to be tweekable without having to juggle > the testcase around too much. */ > -/* { dg-final { scan-tree-dump-times "block 5, loop depth 0, count 0, freq \[6-9\]\[0-9\]\[0-9\]\[0-9\]" 3 "profile_estimate" } } */ > +/* { dg-final { scan-tree-dump "B \\\[\[6-9\]\[0-9\]\\\..*\\\]" "profile_estimate" } } */ > -- > 2.13.0