From patchwork Tue Nov 19 19:08:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1197595 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-514063-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="i5z2sVnj"; 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 47Hb2h1Kbwz9sPL for ; Wed, 20 Nov 2019 06:08:42 +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=XMr2zMm2dwfDIh6Nax4rJ74dARYMHn4iE0GUBuD/HP7fZC0LjL0x1 wfKDXx/Aox6CMCMu/hyouGEJ0XcfRZTksoebuJExf53OvowbquoK+IXmjsAnbNeh lcl0db+oyzadPvj5VjGyerKPaLhCOUjNWy4rpIUmolsnu11NstxdSI= 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=xrsTQIavE41ke98x87vU+SHizdQ=; b=i5z2sVnjG28XOrVF+9jr BZSXJ04MuA4Hjr3Da2Mw4BnBN4ZJv2cwLxGd6ZcKMClzjt7LK8x0Q2lYhVio1tB1 u/chlKCUb/ypYO/qAvzq0w5F4QWEUSge8OsiEQ38iP5mT6h5V+hLKOrKHXMsYIe+ vYFTkj919/1u8rrfhtpkI60= Received: (qmail 67647 invoked by alias); 19 Nov 2019 19:08:34 -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 67634 invoked by uid 89); 19 Nov 2019 19:08:34 -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=compensated, growth, cgraph, cgraph_edge 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; Tue, 19 Nov 2019 19:08:31 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 150D1287307; Tue, 19 Nov 2019 20:08:29 +0100 (CET) Date: Tue, 19 Nov 2019 20:08:29 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Minor speedup in estimate_edge_badness Message-ID: <20191119190829.uign4sb72unhhwd5@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch avoids some extra calculation in edge_badness. Bootstrapped/regtested x86_64-linux. Comitted. * ipa-inline.c (inlining_speedup): New function. (edge_badness): Use it. Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 278441) +++ ipa-inline.c (working copy) @@ -768,6 +768,33 @@ compute_inlined_call_time (struct cgraph return time; } +/* Determine time saved by inlininig EDGE of frequency FREQ + where callee's runtime w/o inlineing is UNINLINED_TYPE + and with inlined is INLINED_TYPE. */ + +inline sreal +inlining_speedup (struct cgraph_edge *edge, + sreal freq, + sreal uninlined_time, + sreal inlined_time) +{ + sreal speedup = uninlined_time - inlined_time; + /* Handling of call_time should match one in ipa-inline-fnsummary.c + (estimate_edge_size_and_time). */ + sreal call_time = ipa_call_summaries->get (edge)->call_stmt_time; + + if (freq > 0) + { + speedup = (speedup + call_time); + if (freq != 1) + speedup = speedup * freq; + } + else if (freq == 0) + speedup = speedup >> 11; + gcc_checking_assert (speedup >= 0); + return speedup; +} + /* Return true if the speedup for inlining E is bigger than PARAM_MAX_INLINE_MIN_SPEEDUP. */ @@ -1149,10 +1176,8 @@ edge_badness (struct cgraph_edge *edge, sreal numerator, denominator; int overall_growth; sreal freq = edge->sreal_frequency (); - sreal inlined_time = compute_inlined_call_time (edge, edge_time, freq); - numerator = (compute_uninlined_call_time (edge, unspec_edge_time, freq) - - inlined_time); + numerator = inlining_speedup (edge, freq, unspec_edge_time, edge_time); if (numerator <= 0) numerator = ((sreal) 1 >> 8); if (caller->count.ipa ().nonzero_p ()) @@ -1235,16 +1260,14 @@ edge_badness (struct cgraph_edge *edge, fprintf (dump_file, " %f: guessed profile. frequency %f, count %" PRId64 " caller count %" PRId64 - " time w/o inlining %f, time with inlining %f" + " time saved %f" " overall growth %i (current) %i (original)" " %i (compensated)\n", badness.to_double (), freq.to_double (), edge->count.ipa ().initialized_p () ? edge->count.ipa ().to_gcov_type () : -1, caller->count.ipa ().initialized_p () ? caller->count.ipa ().to_gcov_type () : -1, - compute_uninlined_call_time (edge, - unspec_edge_time, freq).to_double (), - inlined_time.to_double (), + inlining_speedup (edge, freq, unspec_edge_time, edge_time).to_double (), estimate_growth (callee), callee_info->growth, overall_growth); }