From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id 373373858C33 for ; Fri, 21 Oct 2022 01:52:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 373373858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666317130; x=1697853130; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=q2DJbCoNR+QqWzZDpTHkqw8k3b+iDEx151P8cSJqWwI=; b=eXYhZReWUdNNn74Xm7/O58QuSu47A3wPXJ4aT4rpSv/2tfHQ4RoDor09 9M3C0VVd7O3WlkiZJcRZcSO8M8OB3plmDWd9HOVOLdK+YJpfT2hltJudM 2bWVcbKHVnry7OJPEXpJPem+jL7MnAgvlVTmkbcMmA3/SwJ9ULGt2LS4J H7wDBWq/OKyBlBatePFwt39raht6nmLtvUhYIsGrW9dCYOW3fOfEOKIZV TTl1yYugSBFV6SIgablYBo4bAdY1Kz16y3EGFxOGTUdNhT7hKQRYg6rZg dagFfuAuZ0JPWLWgM/9mAUIHIFfesiBmw204kstbrOGORRPQtMMbyzBXW A==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="307984390" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="307984390" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 18:52:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="632623679" X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="632623679" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga007.fm.intel.com with ESMTP; 20 Oct 2022 18:52:08 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 20 Oct 2022 18:52:08 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Thu, 20 Oct 2022 18:52:08 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.172) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Thu, 20 Oct 2022 18:52:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8OokPCZmQkFFaBK9j1gsSwQ0tuRExrv+pqwxytCAQDYuuV06kjcFiAi/5Hs3a+frPFlTmhZZW2J2C1PqUgPEjqfwwb6ulfnUVKLn14qPgDbUaPJV/LrhiVxGvfho0f/EpuQEXI0klQMSFz6L3spVA8vkDIeT413mIoMerN4CL6XMm3MN8JMshDL1rNYPieoQbVwPVxm/5s5SN28RBMP3yjM5ld9g0vJth12y+r244+IfgIBz1nrs8Ic+XcVl7sZL4leR3YC6Hk+STWpinaGq7u0Zq6TBgqUqZzDhjXxmZx5F0ESZ3hvimGkOPS53RBv5pCuGh6oLjHZ7X0bD/xfBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NyDFWpF6VIyGIywJDm5ew1R+H79fVjJZYtCCFfFAB3g=; b=dnoPagw3AmZIpXEv/RCS3s2m+5dRxNmSdLIjvlH1lbPSa9OjIGk6+dLWE9NsQy7gz2T26NNDuygSVKQy4bZI8A9lrPxH/YTbuaQA2/1ZVMrub1dOYLry19DBTwY0hMA1MtNKgoff57rG/fIZINWz9HiGpWpze6NRYhWOA2/IQy6JOfg79qaLeuHKoU3/phrtJ/fN97WIeaDiFPP+CEzk73l4p3FyU5t6CCUZFX6tlnMZ9AjlWGq6+HR/fBnPzJ9L/67viaZgdj349dhFWdKf3DF4KU8pA1OfPxmZJ/L9FV4BGI8WfmMvlxlpJ/FUV4HhR+QSAH4UluCBCP+hiQTiTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SJ0PR11MB5600.namprd11.prod.outlook.com (2603:10b6:a03:3ab::16) by SJ0PR11MB5086.namprd11.prod.outlook.com (2603:10b6:a03:2d1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Fri, 21 Oct 2022 01:52:06 +0000 Received: from SJ0PR11MB5600.namprd11.prod.outlook.com ([fe80::ab0c:3707:53c9:656b]) by SJ0PR11MB5600.namprd11.prod.outlook.com ([fe80::ab0c:3707:53c9:656b%7]) with mapi id 15.20.5723.035; Fri, 21 Oct 2022 01:52:06 +0000 From: "Cui, Lili" To: "Cui, Lili" , Jan Hubicka , "jh@suse.cz" CC: "gcc-patches@gcc.gnu.org" , "Liu, Hongtao" , "Lu, Hongjiu" Subject: Ping^3 [PATCH V2] Add attribute hot judgement for INLINE_HINT_known_hot hint. Thread-Topic: Ping^3 [PATCH V2] Add attribute hot judgement for INLINE_HINT_known_hot hint. Thread-Index: AQHY5O+5iNbZPGz9eUu3vBldSE0Oxg== Date: Fri, 21 Oct 2022 01:52:06 +0000 Message-ID: References: <20220920084810.25157-1-lili.cui@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SJ0PR11MB5600:EE_|SJ0PR11MB5086:EE_ x-ms-office365-filtering-correlation-id: 286cda97-57cb-4090-d694-08dab306dba2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MFuZmM1+66U5gHU+cezomRhIhRSa2H6S7PqMeWNhKzcDIyUpvhKqrmHFpV7iDcsAAIkdGhKD/kCnbhbHxiCmrkRWVRqXQF2baudPdYFxpEpDToTYegjyjboHCOj/0bU32GWs8IH38FsAW+4Aq0dPu67r2Yena3SJ+KihDmlJ3SLVbiSYJWdFlHhAAl+zbJeU0qsh4d1+0ar/CbzMxnX4NSeJrm1+cdnlmisjUGsAd7S6gQmaZYZMmiHTWlXAroj49wQcCDbi11rELZSO8ax5GceubJ6TZFQ9MEUXGhwtXw4qpy/3+W/tuwNyAm8WVueZiWQgo+GTeySCRDqTBDwu9Z+Io0favXNBjWNjj2ndAExBu5PVWw0fUGR+qha73dYlLAKIebmBWUEM4wtduJLYJG81j/qij2/vMcPT1wkQxsfAQXpwhpZzhxwxt3q/kJrEjj6UP3578WoO+6cQjH2f2qF7SREltkJXrtS3/iHxqh0J4kJdi8fSkllR+U86325lZ4zm2rrXxpydwX/AQ0d8z50/8DvXpSXKp1oZZDaPeKOIkJY0cmLhq2qP89miZfGHZPgDa0WT8l6Pft7OK53P51DK7qPcknV/8rdIbjLmYtruMLeVVMIwlg4sEZoqreTtGt34MO7KqfMhyIPPXSfQVAIX6J+rF9M4ltAdvAfggvbm4g0IBbJXyNNAaU5HhPRXN/VhNgYkJH7zWH3qM70H+Zmc0jj1xTcJ0RLwhVhRavFYHWmFZ/63WrBpNDk0V55F9zQ3IvnpQ9xSvXSBxIydoW0cwlqyO9XRur0fI1fPAR/Uw5NQ6fxmcc3RzfN8KaHq x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR11MB5600.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(396003)(346002)(39860400002)(376002)(366004)(451199015)(7696005)(26005)(64756008)(52536014)(107886003)(66946007)(83380400001)(478600001)(55016003)(9686003)(186003)(6506007)(5660300002)(110136005)(8936002)(71200400001)(966005)(66476007)(41300700001)(76116006)(66556008)(54906003)(8676002)(4326008)(316002)(2906002)(66446008)(33656002)(122000001)(86362001)(38100700002)(82960400001)(84970400001)(38070700005)(81973001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?VvxQmruzoCTMGaKKPZwtIqMOXGd8PLotsaWGaOry/pU56gOlcUYf3WpVtKOT?= =?us-ascii?Q?dbbtpz8v1tFTnluaXcAYBY/U5XMG3aUrQY33RlIIno+60b0KDlo9pNR2Zv83?= =?us-ascii?Q?bB+8zrTnZXJZd9pHIfc3Rk3223Ucr/3Tn92ibRDsbqX/jt2WzSXDYwv3D8Ia?= =?us-ascii?Q?V2fp7jJYOmmjlQxtkPSvNqUqSasVu0YygIphDg+BGPPx3WV0LoYKGtF/QDDT?= =?us-ascii?Q?eO304WhEx0d7mUO2E2sROrWGlA2whHjhtb8fSLChlFhcBvIgBrlXygyym8zB?= =?us-ascii?Q?+vE4J+zLS1k8Xgtz7ybKF6kONraXb+kAVx3jgI+cTfSWcknpLqK8GKI92yeQ?= =?us-ascii?Q?jYgZyYWpnbma2nNLx5YRFoL44Kha93pmd74Sy7UtxD6QemkuJumDszODT1aY?= =?us-ascii?Q?GEObLZc7/czTx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ASd0gRhlQtvMddOil5?= =?us-ascii?Q?+GzV19eeXlOgsBElPQrYljl2tpOsOY3BeH6u6PWILReIfV4FOrfX7MrRY6UA?= =?us-ascii?Q?PbxcSAI+W46PQE9KmVa5iMUgWEzJb9qkZ8f1eSnI/grp4Zicf+swiJUSjjxJ?= =?us-ascii?Q?aaq0vJLpZTbcoCr/sOqUkCsuEmwmYEU4HdrlU5kwxXjaVxnS7McEBsNM9wb9?= =?us-ascii?Q?/AVxWDqHv0vg88uhwfbrDp4c8X+i+48bxt5rRBEWUUH1VCWu/9wlwiXqVxvk?= =?us-ascii?Q?dpCqvKCyG8v21bua/U5ZR9afOJ5Esb2D7Q2/rcYS?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB5600.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 286cda97-57cb-4090-d694-08dab306dba2 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2022 01:52:06.2091 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: CS0pGPMckYp+t+OFjfR2MLMT5bHRU/Wa+u1VoqsAH6P5kMMN/DCPNvFsFa63jK/I8JbtJveNLzw9cmfymioF/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5086 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 List-Id: Hi Honza, Gentle ping https://gcc.gnu.org/pipermail/gcc-patches/2022-September/60193= 4.html gcc/ChangeLog * ipa-inline-analysis.cc (do_estimate_edge_time): Add function attribute judgement for INLINE_HINT_known_hot hint. gcc/testsuite/ChangeLog: * gcc.dg/ipa/inlinehint-6.c: New test. --- gcc/ipa-inline-analysis.cc | 13 ++++--- gcc/testsuite/gcc.dg/ipa/inlinehint-6.c | 47 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/inlinehint-6.c 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" =20 /* Cached node/edge growths. */ fast_call_summary *edge_growth_cache = =3D NULL; @@ -249,15 +250,19 @@ do_estimate_edge_time (struct cgraph_edge *edge, srea= l *ret_nonspec_time) hints =3D estimates.hints; } =20 - /* 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 saf= ely + identify hot edges and for those we disable size limits. Don't do th= at + when probability that caller will call the callee is low however, sin= ce 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)) + !=3D NULL + && lookup_attribute ("hot", DECL_ATTRIBUTES (edge->callee->decl)) + !=3D NULL)) hints |=3D INLINE_HINT_known_hot; =20 gcc_checking_assert (size >=3D 0); diff --git a/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c b/gcc/testsuite/gcc.dg= /ipa/inlinehint-6.c new file mode 100644 index 00000000000..1f3be641c6d --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/inlinehint-6.c @@ -0,0 +1,47 @@ +/* { dg-options "-O3 -c -fdump-ipa-inline-details -fno-early-inlining -fno= -ipa-cp" } */ +/* { dg-add-options bind_pic_locally } */ + +#define size_t long long int + +struct A +{ + size_t f1, f2, f3, f4; +}; +struct C +{ + struct A a; + size_t b; +}; +struct C x; + +__attribute__((hot)) struct C callee (struct A *a, struct C *c) +{ + c->a=3D(*a); + + if((c->b + 7) & 17) + { + c->a.f1 =3D c->a.f2 + c->a.f1; + c->a.f2 =3D c->a.f3 - c->a.f2; + c->a.f3 =3D c->a.f2 + c->a.f3; + c->a.f4 =3D c->a.f2 - c->a.f4; + c->b =3D c->a.f2; + + } + return *c; +} + +__attribute__((hot)) struct C caller (size_t d, size_t e, size_t f, size_t= g, struct C *c) +{ + struct A a; + a.f1 =3D 1 + d; + a.f2 =3D e; + a.f3 =3D 12 + f; + a.f4 =3D 68 + g; + if (c->b > 0) + return callee (&a, c); + else + return *c; +} + +/* { dg-final { scan-ipa-dump "known_hot" "inline" } } */ + --=20 2.17.1 Thanks, Lili.