From patchwork Sun Nov 10 18:13:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1192653 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-512899-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="RixNOFWE"; 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 47B2F01sRSz9sPc for ; Mon, 11 Nov 2019 05:13:22 +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=RZXmOtotXfFfbG5/JM/KtKidzUunoMuLyAK/6LSa17I2J7qLRlOwu 6t2ss0RUFQofJRHiA/6YKV+crshSYPaf896WfFpXCBuqcLXmkjUa3wjlzKGmnvaP 1j3wF3mPaFxJzJxn1E6dzuKsq0Ik3n9M0TNsmWvwm10MPL7Uypx72s= 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=VXH1Im7h4Jl/ZTnHiTQp+wHo710=; b=RixNOFWEMcEbowv3Takh W2wixXs20iDMKaRfVU4j4UP3XVonhxu0pyxvT9WfCyCZRrnCKX5Cj006Mbh+++u4 zxzBv2HpMszsgp5WMDdQGw4Zz2my4AEzXrBjdbEM2hmF3wfiiWHeoavF76ncRjaI l0I+AOTFsZ0Ng9CBZyGn8mI= Received: (qmail 48027 invoked by alias); 10 Nov 2019 18:13:14 -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 48018 invoked by uid 89); 10 Nov 2019 18:13:14 -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=HX-Languages-Length:1494, FIXME, fixme, profiles 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:13:13 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 4561228288F; Sun, 10 Nov 2019 19:13:11 +0100 (CET) Date: Sun, 10 Nov 2019 19:13:11 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Avoid sreal in cgrpah_maybe_hot_p Message-ID: <20191110181311.lirntjqdq2mo5eut@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, while looking into performance issues with too much of sreal use in inliner I nocited that in maybe_hot_p it is used just to hold a fraction which is easily done on profile_counters, too. This has also advantage that it will work with partially guessed static profiles which are there during early inlining. Bootstrapped/regtested x86_64-linux, comitted. * cgraph.c (cgraph_edge::maybe_hot_p): Do not use sreal_frequency. Index: cgraph.c =================================================================== --- cgraph.c (revision 278020) +++ cgraph.c (working copy) @@ -2697,14 +2697,18 @@ cgraph_edge::maybe_hot_p (void) return false; if (caller->frequency == NODE_FREQUENCY_HOT) return true; - /* If profile is now known yet, be conservative. - FIXME: this predicate is used by early inliner and can do better there. */ - if (symtab->state < IPA_SSA) + if (!count.initialized_p ()) return true; - if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE - && sreal_frequency () * 2 < 3) + cgraph_node *where = caller->inlined_to ? caller->inlined_to : caller; + if (!where->count.initialized_p ()) return false; - if (sreal_frequency () * PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION) <= 1) + if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE) + { + if (count.apply_scale (2, 1) < where->count.apply_scale (3, 1)) + return false; + } + else if (count.apply_scale (PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION), 1) + < where->count) return false; return true; }