From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31966 invoked by alias); 31 Mar 2015 12:32:22 -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 31957 invoked by uid 89); 31 Mar 2015 12:32:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ob0-f176.google.com Received: from mail-ob0-f176.google.com (HELO mail-ob0-f176.google.com) (209.85.214.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 31 Mar 2015 12:32:20 +0000 Received: by obbgh1 with SMTP id gh1so23795982obb.1 for ; Tue, 31 Mar 2015 05:32:18 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.144.136 with SMTP id sm8mr32800816obb.63.1427805138350; Tue, 31 Mar 2015 05:32:18 -0700 (PDT) Received: by 10.202.229.72 with HTTP; Tue, 31 Mar 2015 05:32:18 -0700 (PDT) In-Reply-To: <20150329154320.GA67588@kam.mff.cuni.cz> References: <20150329154320.GA67588@kam.mff.cuni.cz> Date: Tue, 31 Mar 2015 12:32:00 -0000 Message-ID: Subject: Re: ipa-cp heuristic tweek From: Ilya Enkovich To: Jan Hubicka Cc: gcc-patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01651.txt.bz2 2015-03-29 18:43 GMT+03:00 Jan Hubicka : > Hi, > this patch improve crafty performance by avoiding ipa-cp clonning of > Search function that specializes the first iteration of the recursion. > The patch is by Martin, I only tested it and cleaned up code in count_callers > and set_single_call_flag > > Bootstrapped/regtested x86_64-linux, comitted. > PR ipa/65478 > * params.def (PARAM_IPA_CP_RECURSION_PENALTY) : New. > (PARAM_IPA_CP_SINGLE_CALL_PENALTY): Likewise. > * ipa-prop.h (ipa_node_params): New flags node_within_scc and > node_calling_single_call. > * ipa-cp.c (count_callers): New function. > (set_single_call_flag): Likewise. > (initialize_node_lattices): Count callers and set single_flag_call if > necessary. > (incorporate_penalties): New function. > (good_cloning_opportunity_p): Use it, dump new flags. > (propagate_constants_topo): Set node_within_scc flag if appropriate. > * doc/invoke.texi (ipa-cp-recursion-penalty, > ipa-cp-single-call-pentalty): Document. > Index: params.def > =================================================================== > --- params.def (revision 221757) > +++ params.def (working copy) > @@ -999,6 +999,18 @@ DEFPARAM (PARAM_IPA_CP_EVAL_THRESHOLD, > "beneficial to clone.", > 500, 0, 0) > > +DEFPARAM (PARAM_IPA_CP_RECURSION_PENALTY, > + "ipa-cp-recursion-penalty", > + "Percentage penalty the recursive functions will receive when they " > + "are evaluated for cloning.", > + 40, 0, 100) > + > +DEFPARAM (PARAM_IPA_CP_SINGLE_CALL_PENALTY, > + "ipa-cp-single-call-penalty", > + "Percentage penalty functions containg a single call to another " > + "function will receive when they are evaluated for cloning.", > + 15, 0, 100) > + > DEFPARAM (PARAM_IPA_MAX_AGG_ITEMS, > "ipa-max-agg-items", > "Maximum number of aggregate content items for a parameter in " > Index: ipa-prop.h > =================================================================== > --- ipa-prop.h (revision 221757) > +++ ipa-prop.h (working copy) > @@ -330,6 +330,10 @@ struct ipa_node_params > /* Node has been completely replaced by clones and will be removed after > ipa-cp is finished. */ > unsigned node_dead : 1; > + /* Node is involved in a recursion, potentionally indirect. */ > + unsigned node_within_scc : 1; > + /* Node is calling a private function called only once. */ > + unsigned node_calling_single_call : 1; > }; > > /* ipa_node_params access functions. Please use these to access fields that > Index: ipa-cp.c > =================================================================== > --- ipa-cp.c (revision 221757) > +++ ipa-cp.c (working copy) > @@ -811,6 +811,41 @@ set_all_contains_variable (struct ipcp_p > return ret; > } > > +/* Worker of call_for_symbol_thunks_and_aliases, increment the integer DATA > + points to by the number of callers to NODE. */ > + > +static bool > +count_callers (cgraph_node *node, void *data) > +{ > + int *caller_count = (int *) data; > + > + for (cgraph_edge *cs = node->callers; cs; cs = cs->next_caller) > + /* Local thunks can be handled transparently, but if the thunk can not > + be optimized out, count it as a real use. */ > + if (!cs->caller->thunk.thunk_p || !cs->caller->local.local) > + ++*caller_count; > + return false; > +} > + > +/* Worker of call_for_symbol_thunks_and_aliases, it is supposed to be called on > + the one caller of some other node. Set the caller's corresponding flag. */ > + > +static bool > +set_single_call_flag (cgraph_node *node, void *) > +{ > + cgraph_edge *cs = node->callers; > + /* Local thunks can be handled transparently, skip them. */ > + while (cs && cs->caller->thunk.thunk_p && cs->caller->local.local) > + cs = cs->next_caller; > + if (cs) > + { > + gcc_assert (!cs->next_caller); This assert assumes the only non-thunk caller is always at the end of a callers list. Is it actually guaranteed? > + IPA_NODE_REF (cs->caller)->node_calling_single_call = true; > + return true; > + } > + return false; > +} > + > /* Initialize ipcp_lattices. */ Thanks, Ilya