From patchwork Sun Nov 10 18:18:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1192655 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-512901-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="uqgnmGt1"; 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 47B2Md4CC3z9sPc for ; Mon, 11 Nov 2019 05:19:08 +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=KWd5Nz4wXRayCHAKoI3fD+0g4O0PT9FHhjMqNMvKOKnQ12xUVJRk0 GOgCQbpqu2z9BEDCMlVj+3ceWEU1HTaM6YUj0RnfvQ8tDHU7xsM+nnI19SwClhvk mGorB1ruCedT+X608TjWn4WbZ+9qUZCtW1opNS7dOqXrGvJDgh+aAY= 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=D1tQl84I3np0jWa3tcvW+Oooop0=; b=uqgnmGt1Dvwg2RZCzBWw h2V4rS2OC3mUzCeJ/wHTBJGwtuz05LuT91IAQeoERXViA3NNU7m99T9/L5gyBWqD j+jgXXVSYP8dxogakOKaOwVXYQiXJiZJDUDlvDW7smzLX/oYT7ZVLTGwM3qteKQw 6vBuCpzCGi3Ug1MJRDXmPT4= Received: (qmail 55185 invoked by alias); 10 Nov 2019 18:19:01 -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 55176 invoked by uid 89); 10 Nov 2019 18:19:01 -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=11649, cse, sk:unspec_, CSE 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; Sun, 10 Nov 2019 18:19:00 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id CABA528288F; Sun, 10 Nov 2019 19:18:57 +0100 (CET) Date: Sun, 10 Nov 2019 19:18:57 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Avoid even more sreal calculations in inliner Message-ID: <20191110181857.ygrkn3o4f4xi3hqp@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, this patch manually CSEs sreal frequency calculations. Bootstrapped/regtested x86_64-linux, comitted. * ipa-inline.c (compute_uninlined_call_time, compute_inlined_call_time): Take edge frequency as parameter rather than computing it by itself. (big_speedup_p, edge_badness): Manually CSE sreal frequency calculations. Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 278020) +++ ipa-inline.c (working copy) @@ -735,13 +735,13 @@ want_early_inline_function_p (struct cgr inline sreal compute_uninlined_call_time (struct cgraph_edge *edge, - sreal uninlined_call_time) + sreal uninlined_call_time, + sreal freq) { cgraph_node *caller = (edge->caller->inlined_to ? edge->caller->inlined_to : edge->caller); - sreal freq = edge->sreal_frequency (); if (freq > 0) uninlined_call_time *= freq; else @@ -756,14 +756,14 @@ compute_uninlined_call_time (struct cgra inline sreal compute_inlined_call_time (struct cgraph_edge *edge, - sreal time) + sreal time, + sreal freq) { cgraph_node *caller = (edge->caller->inlined_to ? edge->caller->inlined_to : edge->caller); sreal caller_time = ipa_fn_summaries->get (caller)->time; - sreal freq = edge->sreal_frequency (); if (freq > 0) time *= freq; else @@ -787,8 +787,9 @@ big_speedup_p (struct cgraph_edge *e) { sreal unspec_time; sreal spec_time = estimate_edge_time (e, &unspec_time); - sreal time = compute_uninlined_call_time (e, unspec_time); - sreal inlined_time = compute_inlined_call_time (e, spec_time); + sreal freq = e->sreal_frequency (); + sreal time = compute_uninlined_call_time (e, unspec_time, freq); + sreal inlined_time = compute_inlined_call_time (e, spec_time, freq); cgraph_node *caller = (e->caller->inlined_to ? e->caller->inlined_to : e->caller); @@ -1164,9 +1165,10 @@ edge_badness (struct cgraph_edge *edge, { sreal numerator, denominator; int overall_growth; - sreal inlined_time = compute_inlined_call_time (edge, edge_time); + 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) + numerator = (compute_uninlined_call_time (edge, unspec_edge_time, freq) - inlined_time); if (numerator <= 0) numerator = ((sreal) 1 >> 8); @@ -1198,14 +1200,14 @@ edge_badness (struct cgraph_edge *edge, && callee_info->single_caller && !edge->caller->inlined_to /* ... and edges executed only conditionally ... */ - && edge->sreal_frequency () < 1 + && freq < 1 /* ... consider case where callee is not inline but caller is ... */ && ((!DECL_DECLARED_INLINE_P (edge->callee->decl) && DECL_DECLARED_INLINE_P (caller->decl)) /* ... or when early optimizers decided to split and edge frequency still indicates splitting is a win ... */ || (callee->split_part && !caller->split_part - && edge->sreal_frequency () * 100 + && freq * 100 < PARAM_VALUE (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY) /* ... and do not overwrite user specified hints. */ @@ -1256,11 +1258,11 @@ edge_badness (struct cgraph_edge *edge, " overall growth %i (current) %i (original)" " %i (compensated)\n", badness.to_double (), - edge->sreal_frequency ().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).to_double (), + unspec_edge_time, freq).to_double (), inlined_time.to_double (), estimate_growth (callee), callee_info->growth, overall_growth);