From patchwork Mon Jun 3 04:19:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 248169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 13D8B2C00A9 for ; Mon, 3 Jun 2013 14:20:08 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=xxypEH9AlnpXDsLwF9 TSPUyRj5PCGoqXBU+ovwnkBVa/sl4RxTNChoAH7eoGE+VeGiUu3/GCN9nPd1CeNu P/3T9yUz7SxxhsB4sKL/1U38NAMLDUnXW60WE/fV7WcFqPwCzEItIbwAHeaXj7Rf +nnG1Waw6Oaw3uh92CqRgiNas= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=RSEGKym+YJckDfhQ3LO4uvQe 9l4=; b=M5HcXY45UMxj2b8MQM8sbik+QUxiGWslnGyHKLBMaGgJtHwJeETqPeyY qN5ER2uAgn24NlsO/kx5q3ygh0TM/gvJTii8NL756JzjbsXCp/RiO/jf1gR4QL+f cLe7XBQ5VAg7Kk8UQvsIDXvUdhhzO8Kt8gWAIoegkMp3fQ92XQI= Received: (qmail 27699 invoked by alias); 3 Jun 2013 04:20:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27620 invoked by uid 89); 3 Jun 2013 04:19:59 -0000 X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-ee0-f50.google.com (HELO mail-ee0-f50.google.com) (74.125.83.50) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 03 Jun 2013 04:19:58 +0000 Received: by mail-ee0-f50.google.com with SMTP id d49so186149eek.23 for ; Sun, 02 Jun 2013 21:19:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=LZ5q9ZGkhJr/Ly7+phn0cV+F2gtMJfJuA14wmfVDTZg=; b=haM+YWfsVHSLDbfhIP/Nqv/a3DMR7Ry/FkrU9w00HDk2nJ0YFBpKRWMoRzu+t/yH7E OaMiKZzid8m+HNuwPEzJbsF+BVxjyzvL1L1Z+UOBJnpS9mZVHJ6ULUIda4P3ByEgeNaq 7wGXdgEzj3Fcg2YN+4oY62ejlrA9+cuWN1DIvYHvxgspuixPN/REaNijVT7JrukQGXk5 sKOYb4yafavXYtiiHBZDOUudF8QhwxFFmFeAGBaO9sHOeGb0BGwFyCczxDk9pSsD+9lK l2FQAUrh428l8P0NMy5deMZMeBuwsejNYp1Jgb6jiEIpeKjFljGFJ40A8Awf+m0roa5E gX7w== MIME-Version: 1.0 X-Received: by 10.14.206.136 with SMTP id l8mr21858442eeo.26.1370233196379; Sun, 02 Jun 2013 21:19:56 -0700 (PDT) Received: by 10.14.220.9 with HTTP; Sun, 2 Jun 2013 21:19:56 -0700 (PDT) In-Reply-To: References: Date: Sun, 2 Jun 2013 21:19:56 -0700 Message-ID: Subject: Re: [GOOGLE] Unrestrict early inline restrictions for AutoFDO From: Dehao Chen To: Xinliang David Li Cc: GCC Patches , Teresa Johnson X-Gm-Message-State: ALoCoQmHhVkbXRTCWtKFnptMMYEmhZd2inDZ4Mp/hjkU8MrrWvEYld+Ej7IimC88Wv+tOyukBXgGsBbmK0lvHgV0HPBafwtrD1tuPzvu0xCuHX4IGKySH2yuyaUe7sJUMaBJQ6R3N4h9NPP00cTexSAqEpIDmXkkSQfkgdZ1/arXzAg0kQHV0JICQ519BsqW20DrpLTu6q2p I've updated the patch to check it at ipa-inline: Thanks, Dehao On Sun, Jun 2, 2013 at 9:08 PM, Xinliang David Li wrote: > If the purpose of the fix is to filter early inlinings with code > growth in autoFDO, the proposed fix is the wrong way to do -- it > changes the meaning of cgraph_maybe_hot_edge_p. > > David > > On Sun, Jun 2, 2013 at 7:25 PM, Dehao Chen wrote: >> On Sun, Jun 2, 2013 at 7:14 PM, Xinliang David Li wrote: >>> >>> auto profile info is not available yet in early inlining, why would >>> this change make any difference? >> >> Because the check of PARAM_EARLY_INLINING_INSNS is after the check of >> cgraph_maybe_hot_edge_p in early inline. If >> cgraph_maybe_hot_edge_p fails, the early inline will not happen even >> if growth is less than PARAM_EARLY_INLINING_INSNS. >> >>> >>> Can you just reset the max_iters to a >>> higher value for autoFDO? >> >> We could do that, but it could still lead to some code bloat because >> recursive inlines can happen for at most, say 10, iterations. >> >> Dehao >> >>> >>> David >>> >>> On Sun, Jun 2, 2013 at 6:21 PM, Dehao Chen wrote: >>> > The patch was committed to google-4_8, but it causes problem because >>> > einline sets PARAM_EARLY_INLINING_INSNS = 11. This will cause >>> > recursive inlining at einline stage (e.g. main->foo, foo->bar, >>> > bar->foo) when autofdo is enabled. >>> > >>> > The following patch can fix the problem by doing more targetted early inlining: >>> > >>> > Index: gcc/predict.c >>> > =================================================================== >>> > --- gcc/predict.c (revision 199593) >>> > +++ gcc/predict.c (working copy) >>> > @@ -175,6 +175,8 @@ cgraph_maybe_hot_edge_p (struct cgraph_edge *edge) >>> > && !maybe_hot_count_p (NULL, >>> > edge->count)) >>> > return false; >>> > + if (flag_auto_profile) >>> > + return false; >>> > if (edge->caller->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED >>> > || (edge->callee >>> > && edge->callee->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED)) >>> > >>> > Performance testing on-going... >>> > >>> > Dehao >>> > >>> > On Wed, May 29, 2013 at 3:44 PM, Dehao Chen wrote: >>> >> OK, I'll commit the early inline part. >>> >> >>> >> Dehao >>> >> >>> >> On Wed, May 29, 2013 at 10:00 AM, Xinliang David Li wrote: >>> >>> The early inlining part is ok. The tracer optimization should be >>> >>> revisited -- we should have more fine grain control on it (for >>> >>> instance, based on FDO summary -- but that should be common to >>> >>> FDO/LIPO). >>> >>> >>> >>> David >>> >>> >>> >>> On Wed, May 29, 2013 at 9:39 AM, Dehao Chen wrote: >>> >>>> In gcc4-8, the max einline iterations are restricted to 1. For >>> >>>> AutoFDO, this is bad because early inline is not size restricted. This >>> >>>> patch allows einline to do multiple iterations in AutoFDO. It also >>> >>>> enables tracer optimization in AutoFDO. >>> >>>> >>> >>>> Bootstrapped and passed regression test. >>> >>>> >>> >>>> OK for googel-4_8? >>> >>>> >>> >>>> Thanks, >>> >>>> Dehao >>> >>>> >>> >>>> Index: gcc/ipa-inline.c >>> >>>> =================================================================== >>> >>>> --- gcc/ipa-inline.c (revision 199416) >>> >>>> +++ gcc/ipa-inline.c (working copy) >>> >>>> @@ -2161,7 +2161,8 @@ early_inliner (void) >>> >>>> { >>> >>>> /* We iterate incremental inlining to get trivial cases of indirect >>> >>>> inlining. */ >>> >>>> - while (iterations < PARAM_VALUE (PARAM_EARLY_INLINER_MAX_ITERATIONS) >>> >>>> + while ((flag_auto_profile >>> >>>> + || iterations < PARAM_VALUE (PARAM_EARLY_INLINER_MAX_ITERATIONS)) >>> >>>> && early_inline_small_functions (node)) >>> >>>> { >>> >>>> timevar_push (TV_INTEGRATION); >>> >>>> Index: gcc/opts.c >>> >>>> =================================================================== >>> >>>> --- gcc/opts.c (revision 199416) >>> >>>> +++ gcc/opts.c (working copy) >>> >>>> @@ -1644,6 +1644,8 @@ common_handle_option (struct gcc_options *opts, >>> >>>> opts->x_flag_peel_loops = value; >>> >>>> if (!opts_set->x_flag_value_profile_transformations) >>> >>>> opts->x_flag_value_profile_transformations = value; >>> >>>> + if (!opts_set->x_flag_tracer) >>> >>>> + opts->x_flag_tracer = value; >>> >>>> if (!opts_set->x_flag_inline_functions) >>> >>>> opts->x_flag_inline_functions = value; >>> >>>> if (!opts_set->x_flag_ipa_cp) Index: gcc/ipa-inline.c =================================================================== --- gcc/ipa-inline.c (revision 199593) +++ gcc/ipa-inline.c (working copy) @@ -434,6 +434,16 @@ want_early_inline_function_p (struct cgraph_edge * if (growth <= PARAM_VALUE (PARAM_EARLY_INLINING_INSNS_ANY)) ; + else if (flag_auto_profile) + { + if (dump_file) + fprintf (dump_file, " will not early inline: %s/%i->%s/%i, " + "call is cold in profiling and code would grow by %i\n", + xstrdup (cgraph_node_name (e->caller)), e->caller->uid, + xstrdup (cgraph_node_name (callee)), callee->uid, + growth); + want_inline = false; + } else if (!cgraph_maybe_hot_edge_p (e)) { if (dump_file)