From patchwork Tue Sep 20 08:48:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1356054wrt; Tue, 20 Sep 2022 01:49:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4x1fGocLXjRLe2Af96V6ACI5a73tsPrIeqZKP591qQgLGcixdvgJ9OBCNngWKwCtmiHgUN X-Received: by 2002:a17:907:2cea:b0:77c:59aa:c00f with SMTP id hz10-20020a1709072cea00b0077c59aac00fmr15792753ejc.73.1663663740503; Tue, 20 Sep 2022 01:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663663740; cv=none; d=google.com; s=arc-20160816; b=lzm0/MME84qZmK/+xb9EFSirbqKt2DI35vZfPfQ7wYzPqfk70JxVhRMpiCLNc4eVgx k7MvQBrFcPkcdbY3F6wVecwEnQiW4bOCTiPmdcwvhPdj+LnWcOJgddYors4Shpge8BB+ khbJGxOF/9gBmKsZ04+FpjgbZ1+JNwo+XeWaoo9TaIUE6ns683T1v9hKdQ/jMBDKvnYO O+ZP+ZAEoYBu3ov7Ja14Ps5nyxHJO1tc+F4DQ5jr3GcP3mmUW20wiZz2CytC6eMfYIUT XdPOi+VlPMdOwS7IDVcDIT7F6g6OK+r0osZPYGFCpK5ooAx0BAhLSsOGZu7szTsZHqZX F6Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=iLYQPUEe5vnTK/Naeb4aB3Z1nSxtIOeMkB0FMNtVi6M=; b=e8jXEdSuQSieHhIIIeXsMIJbHXbpl+rj8KDIjjxxk+uMRH3tVn9cfq+Zvdg35etRbk mHOh+5Y6TLLcinPd4nyMKrqVxqVb/F6GwXC4o7J2JYKLpBU954+Na5L8oqN28pnOIEOP Wa5p4hZimG7FzlV+X/qKUpCOyR8oJPfrzhU5qf5Mvs9NkPDzA1SRaDX1Pb6bTyZBib5E rTJQSIjTuAkQ9ga/53Si4dj+AYDouth2w6TfwwXWZjtn1DEQuRiiyrrswN/x4Ow+bVhU Qoa8dEcKU4i+hDcWRxb3td3Aied8gFGclnyhhAB0lrHAfiTfTsH8EEqTmOQkvyPzfZs2 YEyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Y/I18QWE"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i31-20020a0564020f1f00b0044e9ca6880bsi1081938eda.364.2022.09.20.01.49.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 01:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Y/I18QWE"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D755A385841F for ; Tue, 20 Sep 2022 08:48:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D755A385841F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663663738; bh=iLYQPUEe5vnTK/Naeb4aB3Z1nSxtIOeMkB0FMNtVi6M=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Y/I18QWE2/Wwglfvjz4WHVgrPUd2Ux/Io82sUD4cg0V28a4BMzHdC931uQFX0GTdH B8Y+/9bskfgIE6d4NnZpUO2OjuoGC2I+vcey8ChcbRTAvHEcWSm3aNLTKyGr4OkWdq C7qA7KftArxfx3r6NfPuLJzArko0mfBPg7fVWDWs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id 3012B3858D28 for ; Tue, 20 Sep 2022 08:48:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3012B3858D28 X-IronPort-AV: E=McAfee;i="6500,9779,10475"; a="361377431" X-IronPort-AV: E=Sophos;i="5.93,330,1654585200"; d="scan'208";a="361377431" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2022 01:48:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,330,1654585200"; d="scan'208";a="722653572" Received: from scymds02.sc.intel.com ([10.82.73.244]) by fmsmga002.fm.intel.com with ESMTP; 20 Sep 2022 01:48:13 -0700 Received: from shgcc10.sh.intel.com (shgcc10.sh.intel.com [10.239.154.125]) by scymds02.sc.intel.com with ESMTP id 28K8mAnE005831; Tue, 20 Sep 2022 01:48:11 -0700 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Add attribute hot judgement for INLINE_HINT_known_hot hint. Date: Tue, 20 Sep 2022 16:48:10 +0800 Message-Id: <20220920084810.25157-1-lili.cui@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Cui,Lili via Gcc-patches" From: "Li, Pan2 via Gcc-patches" Reply-To: "Cui,Lili" Cc: hongtao.liu@intel.com, hongjiu.lu@intel.com, hubicka@ucw.cz Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1744477870653067484?= X-GMAIL-MSGID: =?utf-8?q?1744477870653067484?= Hi Honza, This patch is to add attribute hot judgement for INLINE_HINT_known_hot hint. We set up INLINE_HINT_known_hot hint only when we have profile feedback, now add function attribute judgement for it, when both caller and callee have __attribute__((hot)), we will also set up INLINE_HINT_known_hot hint for it. With this patch applied Ratio Codesize ADL Multi-copy: 538.imagic_r 16.7% 1.6% SPR Multi-copy: 538.imagic_r 15% 1.7% ICX Multi-copy: 538.imagic_r 15.2% 1.7% CLX Multi-copy: 538.imagic_r 12.7% 1.7% Znver3 Multi-copy: 538.imagic_r 10.6% 1.5% Bootstrap and regtest pending on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Lili. gcc/ChangeLog * ipa-inline-analysis.cc (do_estimate_edge_time): Add function attribute judgement for INLINE_HINT_known_hot hint. --- gcc/ipa-inline-analysis.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gcc/ipa-inline-analysis.cc b/gcc/ipa-inline-analysis.cc index 1ca685d1b0e..7bd29c36590 100644 --- a/gcc/ipa-inline-analysis.cc +++ b/gcc/ipa-inline-analysis.cc @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-utils.h" #include "cfgexpand.h" #include "gimplify.h" +#include "attribs.h" /* Cached node/edge growths. */ fast_call_summary *edge_growth_cache = NULL; @@ -249,15 +250,19 @@ do_estimate_edge_time (struct cgraph_edge *edge, sreal *ret_nonspec_time) hints = estimates.hints; } - /* When we have profile feedback, we can quite safely identify hot - edges and for those we disable size limits. Don't do that when - probability that caller will call the callee is low however, since it + /* When we have profile feedback or function attribute, we can quite safely + identify hot edges and for those we disable size limits. Don't do that + when probability that caller will call the callee is low however, since it may hurt optimization of the caller's hot path. */ - if (edge->count.ipa ().initialized_p () && edge->maybe_hot_p () + if ((edge->count.ipa ().initialized_p () && edge->maybe_hot_p () && (edge->count.ipa () * 2 > (edge->caller->inlined_to ? edge->caller->inlined_to->count.ipa () : edge->caller->count.ipa ()))) + || (lookup_attribute ("hot", DECL_ATTRIBUTES (edge->caller->decl)) + != NULL + && lookup_attribute ("hot", DECL_ATTRIBUTES (edge->callee->decl)) + != NULL)) hints |= INLINE_HINT_known_hot; gcc_checking_assert (size >= 0);