From patchwork Sat Nov 9 17:39:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1192467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512881-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PgjFZVni"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 479PX95kvtz9s4Y for ; Sun, 10 Nov 2019 04:39:19 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=plPpIWNqJ4WlhNCEe+No5CUvTS0pkmsq2sQqcOKTTmTAkS41/Qwuy cpJlkexRHGM6JqvcawFMzm0JbGNQzJHx9d+skApoVCS0wC3kIJP06YyaEwjh6CIH llwl14DBSpPq9lnZJUcEfdXG08np9CYRhh+hk6n9hmjEk++bPR7yd8= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=SDNRnEzx6tQ5YDWkx+/lfzsxmlc=; b=PgjFZVni80elepfvXFpy XLuBBgPnIh43kxdJrHR7YAsZxBhCvQq+EWdWbA5DGYO0P7RRITXvz+Xi+51ft215 CdpTpMtUTWIVIoroNs05Yh/cby+WRUREXjjboyJjfnm0NpI2OlPkEgc/mtKpCtPV ADHZC3OFpwrnT0tAbmvNTp8= Received: (qmail 78120 invoked by alias); 9 Nov 2019 17:39:10 -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 78110 invoked by uid 89); 9 Nov 2019 17:39:10 -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 autolearn=ham version=3.3.1 spammy=honza, ipafnsummaryc, ipa-fnsummary.c, UD:ipa-fnsummary.c 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; Sat, 09 Nov 2019 17:39:07 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id CC4D228288C; Sat, 9 Nov 2019 18:39:04 +0100 (CET) Date: Sat, 9 Nov 2019 18:39:04 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Some minor ipa-fnsummary speedups Message-ID: <20191109173904.vxwymml2lphe37uz@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch prevents ipa-fnsummary from calculating things that are not going to be used. Bootstrapped/regtested x86_64-linux, comitted. Honza * ipa-fnsummary.c (estimate_edge_size_and_time): Do not call estimate_edge_devirt_benefit when not computing hints; do not compute time when not asked for. (estimate_calls_size_and_time): Pass NULL hints and time when these are not computed; do not evaluate hint predicates when these are not computed. (ipa_merge_fn_summary_after_inlining): Do not re-evaluate edge frequency. Index: ipa-fnsummary.c =================================================================== --- ipa-fnsummary.c (revision 278004) +++ ipa-fnsummary.c (working copy) @@ -2894,16 +2894,17 @@ estimate_edge_size_and_time (struct cgra int call_size = es->call_stmt_size; int call_time = es->call_stmt_time; int cur_size; - if (!e->callee + if (!e->callee && hints && e->maybe_hot_p () && estimate_edge_devirt_benefit (e, &call_size, &call_time, - known_vals, known_contexts, known_aggs) - && hints && e->maybe_hot_p ()) + known_vals, known_contexts, known_aggs)) *hints |= INLINE_HINT_indirect_call; cur_size = call_size * ipa_fn_summary::size_scale; *size += cur_size; if (min_size) *min_size += cur_size; - if (prob == REG_BR_PROB_BASE) + if (!time) + ; + else if (prob == REG_BR_PROB_BASE) *time += ((sreal)call_time) * e->sreal_frequency (); else *time += ((sreal)call_time * prob) * e->sreal_frequency (); @@ -3235,8 +3236,11 @@ ipa_call_context::estimate_size_and_time } } - estimate_calls_size_and_time (m_node, &size, &min_size, &time, &hints, m_possible_truths, + estimate_calls_size_and_time (m_node, &size, &min_size, + ret_time ? &time : NULL, + ret_hints ? &hints : NULL, m_possible_truths, m_known_vals, m_known_contexts, m_known_aggs); + sreal nonspecialized_time = time; for (i = 0; vec_safe_iterate (info->size_time_table, i, &e); i++) @@ -3260,6 +3264,8 @@ ipa_call_context::estimate_size_and_time known to be constant in a specialized setting. */ if (nonconst) size += e->size; + if (!ret_time) + continue; nonspecialized_time += e->time; if (!nonconst) ; @@ -3295,16 +3301,19 @@ ipa_call_context::estimate_size_and_time if (time > nonspecialized_time) time = nonspecialized_time; - if (info->loop_iterations - && !info->loop_iterations->evaluate (m_possible_truths)) - hints |= INLINE_HINT_loop_iterations; - if (info->loop_stride - && !info->loop_stride->evaluate (m_possible_truths)) - hints |= INLINE_HINT_loop_stride; - if (info->scc_no) - hints |= INLINE_HINT_in_scc; - if (DECL_DECLARED_INLINE_P (m_node->decl)) - hints |= INLINE_HINT_declared_inline; + if (ret_hints) + { + if (info->loop_iterations + && !info->loop_iterations->evaluate (m_possible_truths)) + hints |= INLINE_HINT_loop_iterations; + if (info->loop_stride + && !info->loop_stride->evaluate (m_possible_truths)) + hints |= INLINE_HINT_loop_stride; + if (info->scc_no) + hints |= INLINE_HINT_in_scc; + if (DECL_DECLARED_INLINE_P (m_node->decl)) + hints |= INLINE_HINT_declared_inline; + } size = RDIV (size, ipa_fn_summary::size_scale); min_size = RDIV (min_size, ipa_fn_summary::size_scale); @@ -3604,6 +3613,7 @@ ipa_merge_fn_summary_after_inlining (str gcc_assert (map < ipa_get_param_count (params_summary)); } } + sreal freq = edge->sreal_frequency (); for (i = 0; vec_safe_iterate (callee_info->size_time_table, i, &e); i++) { predicate p; @@ -3620,7 +3630,7 @@ ipa_merge_fn_summary_after_inlining (str toplev_predicate); if (p != false && nonconstp != false) { - sreal add_time = ((sreal)e->time * edge->sreal_frequency ()); + sreal add_time = ((sreal)e->time * freq); int prob = e->nonconst_predicate.probability (callee_info->conds, clause, es->param); add_time = add_time * prob / REG_BR_PROB_BASE;