From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62410 invoked by alias); 9 Aug 2018 12:55:24 -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 62401 invoked by uid 89); 9 Aug 2018 12:55:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=Hx-languages-length:2971, rdiv 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; Thu, 09 Aug 2018 12:55:22 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A7EC054229D; Thu, 9 Aug 2018 14:55:19 +0200 (CEST) Date: Thu, 09 Aug 2018 12:55:00 -0000 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Introduce __builtin_expect_with_probability (PR target/83610). Message-ID: <20180809125519.GM12595@kam.mff.cuni.cz> References: <20180731092407.GF29444@kam.mff.cuni.cz> <905756a5-4479-bf8e-cb59-ebdf26001729@suse.cz> <20180807122345.GB86326@kam.mff.cuni.cz> 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: 2018-08/txt/msg00625.txt.bz2 > gcc/ChangeLog: > > 2018-08-09 Martin Liska > > PR target/83610 > * builtin-types.def (BT_FN_LONG_LONG_LONG_DOUBLE): Add new > function type. > * builtins.c (expand_builtin_expect_with_probability): > New function. > (expand_builtin_expect_with_probability): New function. > (build_builtin_expect_predicate): Add new argumnet probability > for BUILT_IN_EXPECT_WITH_PROBABILITY. > (fold_builtin_expect): > (fold_builtin_2): > (fold_builtin_3): > * builtins.def (BUILT_IN_EXPECT_WITH_PROBABILITY): > * builtins.h (fold_builtin_expect): Set new argument. > * doc/extend.texi: Document __builtin_expect_with_probability. > * doc/invoke.texi: Likewise. > * gimple-fold.c (gimple_fold_call): Pass new argument. > * ipa-fnsummary.c (find_foldable_builtin_expect): Handle > also BUILT_IN_EXPECT_WITH_PROBABILITY. > * predict.c (get_predictor_value): New function. > (expr_expected_value): Add new argument probability. Assume > that predictor and probability are always non-null. > (expr_expected_value_1): Likewise. For __builtin_expect and > __builtin_expect_with_probability set probability. Handle > combination in binary expressions. > (tree_predict_by_opcode): Simplify code by simply calling > get_predictor_value. > (pass_strip_predict_hints::execute): Add handling of > BUILT_IN_EXPECT_WITH_PROBABILITY. > * predict.def (PRED_BUILTIN_EXPECT_WITH_PROBABILITY): Add > new predictor. > * tree.h (DECL_BUILT_IN_P): New function. > > gcc/testsuite/ChangeLog: > > 2018-08-09 Martin Liska > > PR target/83610 > * gcc.dg/predict-17.c: New test. > * gcc.dg/predict-18.c: New test. > * gcc.dg/predict-19.c: New test. > --- > gcc/builtin-types.def | 2 + > gcc/builtins.c | 65 ++++++++++--- > gcc/builtins.def | 1 + > gcc/builtins.h | 2 +- > gcc/doc/extend.texi | 9 ++ > gcc/doc/invoke.texi | 3 + > gcc/gimple-fold.c | 3 +- > gcc/ipa-fnsummary.c | 1 + > gcc/predict.c | 154 ++++++++++++++++++++---------- > gcc/predict.def | 5 + > gcc/testsuite/gcc.dg/predict-17.c | 13 +++ > gcc/testsuite/gcc.dg/predict-18.c | 31 ++++++ > gcc/testsuite/gcc.dg/predict-19.c | 13 +++ > gcc/tree.h | 6 ++ > 14 files changed, 244 insertions(+), 64 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/predict-17.c > create mode 100644 gcc/testsuite/gcc.dg/predict-18.c > create mode 100644 gcc/testsuite/gcc.dg/predict-19.c > > + if (TREE_CODE (res) == INTEGER_CST > + && TREE_CODE (op0) == INTEGER_CST > + && TREE_CODE (op1) == INTEGER_CST) > + { > + /* Combine binary predictions. */ > + if (*probability != -1 || probability2 != -1) > + { > + HOST_WIDE_INT p1 = get_predictor_value (*predictor, *probability); > + HOST_WIDE_INT p2 = get_predictor_value (predictor2, probability2); > + *probability = p1 * p2 / REG_BR_PROB_BASE; I guess you want to use RDIV here. Eventually we want to move to profile_probability type everywhere but I guess that can be done later. OK, thanks! Honza