From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41853 invoked by alias); 16 Sep 2016 11:36: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 41843 invoked by uid 89); 16 Sep 2016 11:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=H*UA:Coremail, H*x:Coremail, H*F:D*cn, H*r:Coremail X-HELO: pku.edu.cn Received: from mx13.pku.edu.cn (HELO pku.edu.cn) (162.105.129.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Sep 2016 11:36:12 +0000 Received: by ajax-webmail-mailfront04 (Coremail) ; Fri, 16 Sep 2016 19:36:04 +0800 (GMT+08:00) Date: Fri, 16 Sep 2016 12:00:00 -0000 X-CM-HeaderCharset: UTF-8 From: "Yuan, Pengfei" To: "Jan Hubicka" Cc: "Richard Biener" , "GCC Patches" Subject: Re: [PATCH, 5.x/6.x/7.x] Be more conservative in early inliner if FDO is enabled In-Reply-To: <20160916091417.GA29974@kam.mff.cuni.cz> References: <58f49a76.4c20.15712b20e40.Coremail.ypf@pku.edu.cn> <392727ce.b9c7.1572b385ece.Coremail.ypf@pku.edu.cn> <339617a6.8f06.1573166cbaf.Coremail.ypf@pku.edu.cn> <20160916072531.GB69806@kam.mff.cuni.cz> <355e6f53.95d3.1573230b35b.Coremail.ypf@pku.edu.cn> <20160916091417.GA29974@kam.mff.cuni.cz> X-SendMailWithSms: false Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8 MIME-Version: 1.0 Message-ID: <6ad18072.d732.15732c834ea.Coremail.ypf@pku.edu.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID:9IFpogAHfCgk2dtXg0UhAA--.11632W X-CM-SenderInfo: yrsqiiarrtilo6sn3hxhgxhubq/1tbiAgAAD1Py7a0LZwAAsA X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= X-SW-Source: 2016-09/txt/msg01043.txt.bz2 > > I also like a new param better as it avoids a new magic constant and > > makes playing with > > it easier (your patch removes the ability to do statistics like you did via the > > early-inlining-insns parameter by forcing it to two). > > Hmm, you are right that you do not know if this particular function will get > profile (forgot about that). Still, please use two params - it is more > consistent with what we have now and we may make it profile specific in > future.. > > Honza > > > > Thanks, > > Richard. A new patch for trunk is attached. Regards, Yuan, Pengfei 2016-09-16 Yuan Pengfei * doc/invoke.texi (--param early-inlining-insns-feedback): New. * ipa-inline.c (want_early_inline_function_p): Use PARAM_EARLY_INLINING_INSNS_FEEDBACK when FDO is enabled. * params.def (PARAM_EARLY_INLINING_INSNS_FEEDBACK): Define. (PARAM_EARLY_INLINING_INSNS): Change help string accordingly. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 8eb5eff..6e7659a 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -9124,12 +9124,18 @@ given call expression. This parameter limits inlining only to call expressions whose probability exceeds the given threshold (in percents). The default value is 10. @item early-inlining-insns +@itemx early-inlining-insns-feedback Specify growth that the early inliner can make. In effect it increases the amount of inlining for code having a large abstraction penalty. The default value is 14. +The @option{early-inlining-insns-feedback} parameter is used only when +profile feedback-directed optimizations are enabled (by +@option{-fprofile-generate} or @option{-fprofile-use}). +The default value is 2. + @item max-early-inliner-iterations Limit of iterations of the early inliner. This basically bounds the number of nested indirect calls the early inliner can resolve. Deeper chains are still handled by late inlining. diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 5c9366a..e028c08 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -594,10 +594,17 @@ want_early_inline_function_p (struct cgraph_edge *e) } else { int growth = estimate_edge_growth (e); + int growth_limit; int n; + if ((profile_arc_flag && !flag_test_coverage) + || (flag_branch_probabilities && !flag_auto_profile)) + growth_limit = PARAM_VALUE (PARAM_EARLY_INLINING_INSNS_FEEDBACK); + else + growth_limit = PARAM_VALUE (PARAM_EARLY_INLINING_INSNS); + if (growth <= 0) ; else if (!e->maybe_hot_p () && growth > 0) @@ -610,9 +617,9 @@ want_early_inline_function_p (struct cgraph_edge *e) xstrdup_for_dump (callee->name ()), callee->order, growth); want_inline = false; } - else if (growth > PARAM_VALUE (PARAM_EARLY_INLINING_INSNS)) + else if (growth > growth_limit) { if (dump_file) fprintf (dump_file, " will not early inline: %s/%i->%s/%i, " "growth %i exceeds --param early-inlining-insns\n", @@ -622,9 +629,9 @@ want_early_inline_function_p (struct cgraph_edge *e) growth); want_inline = false; } else if ((n = num_calls (callee)) != 0 - && growth * (n + 1) > PARAM_VALUE (PARAM_EARLY_INLINING_INSNS)) + && growth * (n + 1) > growth_limit) { if (dump_file) fprintf (dump_file, " will not early inline: %s/%i->%s/%i, " "growth %i exceeds --param early-inlining-insns " diff --git a/gcc/params.def b/gcc/params.def index 79b7dd4..91ea513 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -199,12 +199,20 @@ DEFPARAM(PARAM_INLINE_UNIT_GROWTH, DEFPARAM(PARAM_IPCP_UNIT_GROWTH, "ipcp-unit-growth", "How much can given compilation unit grow because of the interprocedural constant propagation (in percent).", 10, 0, 0) -DEFPARAM(PARAM_EARLY_INLINING_INSNS, - "early-inlining-insns", - "Maximal estimated growth of function body caused by early inlining of single call.", - 14, 0, 0) +DEFPARAM (PARAM_EARLY_INLINING_INSNS_FEEDBACK, + "early-inlining-insns-feedback", + "Maximal estimated growth of function body caused by early " + "inlining of single call. Used when profile feedback-directed " + "optimizations are enabled.", + 2, 0, 0) +DEFPARAM (PARAM_EARLY_INLINING_INSNS, + "early-inlining-insns", + "Maximal estimated growth of function body caused by early " + "inlining of single call. Used when profile feedback-directed " + "optimizations are not enabled.", + 14, 0, 0) DEFPARAM(PARAM_LARGE_STACK_FRAME, "large-stack-frame", "The size of stack frame to be considered large.", 256, 0, 0)