From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) by sourceware.org (Postfix) with ESMTPS id 67CA23858405 for ; Mon, 9 May 2022 16:12:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67CA23858405 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=RhkG0GZCnUGkHkVYb+EZRTBK0h0WlzLFrAqIPOV5Qi9DgiBf6t60kO4G7FVciGNVIhvVgHp58ijhuRdGbCLuECipicMcz2nDS8IC3DIxoTIz8P4JPDOAK3HdMUVSfV3deUNGXjxbsvznPk0conl5fS5kjJbvNBHfMBjegrdhFglF8C9SLSt7TQDhemkod2Prt+Kwh+I5nlDGfrz89CRtMEzpbkiVGAXvi0OU2S9bx4gx1zI5+AKV3tO4UDlqSOJqN8cykjmEMqFXjVmvXnBuVWZNXaCPv69fiot1s86a8upzFF1vsw68k1Al0lkw8dBSG8J3Giqo+gKs5pHk8WjujQ== ARC-Message-Signature: i=2; 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=vF8ttStNd9MhRzKSfixf86NEAF+++S3R3KYlXtS7TDo=; b=m876kgp/90zbx9NyuWdxWVb5SmSBphDC6+HsTS7PXHWko771F5SjvSK1p1K2zISo02yk2kdHdr9yfSY3GoNy+RpH6rSE8K6DqELm4SL4Zos18/HTAN2w5GjcGFmepcPwkpH4gLGVVSMz3I2sHsI0HD+d3GzYNxOzQv3MtPcZ9d5J5XoihjZw2u7YZc8Zefdynxd0rTyCjc/uU7vv8pIVZSRu6aeWrVAqDkx9wi1u9ukC1tcnT5K+3S97MaomzmuTbeEEO/sdBH+rWUxMTc3q4+Tn91lIOm5MXYLw8U826lTfGTNDG9gos5BgH1vMx1xLih9uostaXhBfavqFH6PiCQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS8PR04CA0008.eurprd04.prod.outlook.com (2603:10a6:20b:310::13) by AM6PR08MB4868.eurprd08.prod.outlook.com (2603:10a6:20b:c5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.18; Mon, 9 May 2022 16:12:06 +0000 Received: from AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::9f) by AS8PR04CA0008.outlook.office365.com (2603:10a6:20b:310::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23 via Frontend Transport; Mon, 9 May 2022 16:12:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT060.mail.protection.outlook.com (10.152.16.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.15 via Frontend Transport; Mon, 9 May 2022 16:12:06 +0000 Received: ("Tessian outbound 9613c00560a5:v118"); Mon, 09 May 2022 16:12:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 38a1d908a99151bc X-CR-MTA-TID: 64aa7808 Received: from 59f99769ffe6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4264CEF1-DEDF-4EF3-9D41-DD303E8A4801.1; Mon, 09 May 2022 16:11:54 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 59f99769ffe6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 09 May 2022 16:11:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h5Iz7W4Vt/tRehyOSEnn/7czOJN08ZvVqwBLAcgcfFQjpf7K070d8cnm2cLQ1pNb5r4m5jzNQKHeP6qcAVGGJWJpgLQ8vc8E5N20F3UQCIVank++/rdncXhiHeXrMEWuWRWmdUjvmKIfPfpZ0mT8EOON4GSgC1/lzMQFn/7k0WrsGfP8Ak3yk/jCQGydfrpkemxfvG9pXy1sk1ty/SdAOsXAaDlMiSPesbOIrM5Cz0vwWKQi9tPmsQtwe28hg5UplEzxZxg7zRec4d3RcMhWMImTZBV0jyarn7/0VhD25jUtAb7u7QzCHAK9UaqdghMvgoVQ4pqp6xFfwDjGWqJOig== 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=vF8ttStNd9MhRzKSfixf86NEAF+++S3R3KYlXtS7TDo=; b=SzBLP9nWue1DAVJrqWCo6Pmz1EzH18NiGWAOcp/Ce6ePzuzfXvXY1K3cfxTd6BwmA7gITomjvnsqxBwkIGCNzCQ0rbTH9206eoz1SLq1DMrP7gEbrJSEAzpXofOKPU8nU1iycmwPd+1Bz8TDPaE35Yff5VHGbxF5SV6wobKCV5UwzS4m9GKhVgI477WRoPENcl3qSQZP4hzXio11Xj/HB93sfpaRw+9v/oIKsNx3BzI8v/oPu4AQyw/RePK3OSMt7GLBtGiDgVZZwc/l73FaTHYDpc6U310AW3JHj+iAU43sdIOONXoJwVgUUNfN4E65pnl/k13VEbfjetZlOML6tA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Received: from DB6PR0801MB1879.eurprd08.prod.outlook.com (2603:10a6:4:73::9) by AM8PR08MB6579.eurprd08.prod.outlook.com (2603:10a6:20b:356::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.20; Mon, 9 May 2022 16:11:53 +0000 Received: from DB6PR0801MB1879.eurprd08.prod.outlook.com ([fe80::4c79:5ff3:ff33:7ee1]) by DB6PR0801MB1879.eurprd08.prod.outlook.com ([fe80::4c79:5ff3:ff33:7ee1%11]) with mapi id 15.20.5227.021; Mon, 9 May 2022 16:11:53 +0000 From: Wilco Dijkstra To: Kyrylo Tkachov , Richard Sandiford CC: GCC Patches Subject: [PATCH] AArch64: Improve address rematerialization costs Thread-Topic: [PATCH] AArch64: Improve address rematerialization costs Thread-Index: AQHYY78+/Rqz4Ggj7ECwqWuHfdCRtg== Date: Mon, 9 May 2022 16:11:53 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: d741433a-336f-4a10-a37c-08da31d6a97e x-ms-traffictypediagnostic: AM8PR08MB6579:EE_|AM5EUR03FT060:EE_|AM6PR08MB4868:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: HOJEqGpm/hrMPALTJEtzZ23WdATfULaMFsHTF2FmIVNj2pkVHrVBDKlXzQa6it3r/dTs17F0gXqk/rseX8SDuhz6i0UF7NB2ekXfnW4A6xp/34kKClGIut3vc7MhI4kedo2OoeFcvRsasokzJCqf7oV1JaKm4jbT6jPGR1CVvsnQsfyHorHHxnIDssUmdrXvL+wXnGtMJss8QPabdTH3MVLUEBjBW1gDfQEBFRJ4RuRaczgih/cWC2Vb8okCNUvl0jlTaz82GUbOwGzlGItdXqhmcbR4L3fuwaWKJFNQssdg3u7UhGh/EFE2VPfN8qhMe0abBU0kjBVnY4pQL08YKHm/OxYTgTKH0+XUCKYdrZM+REr0ZgEJeaUprrof8g45yt5yk9W1Sac/X8rFGFkHE76AVy+ZBzmvkEdWJgGPUX0C7P7tRb0YRw5dLI0uh5761E5abxqIvrMi1Ky7zC7mVCcncgJP05t1r3yGEB7ojByPhjdt8Q7wcjTm6nh/2LwL1see6tbwR0r3Fg0v9FPF/kZn9E7FRnlwGTH/B8tUlfCnaLNJWcddEWvZAvf8+0VHxQum8d6bhSaDaXL8yulCfUV21d1hqUwKHOKvvnVrWHAuYI+gCsq3c8Cjo0U3rWfYaLrjlG6LRTo18Q0AonspAfjpGeBFmVjqPBexE6lwfh/q7mt+sxDU7MBD1W6QzLoF5oh3wStfbt7o84UvKnoeUg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0801MB1879.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(9686003)(6506007)(66446008)(2906002)(76116006)(64756008)(91956017)(4326008)(7696005)(71200400001)(8676002)(86362001)(33656002)(5660300002)(8936002)(26005)(66556008)(66476007)(66946007)(52536014)(508600001)(38070700005)(55016003)(38100700002)(110136005)(122000001)(186003)(316002)(83380400001)(6636002); DIR:OUT; SFP:1101; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6579 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7521f646-0810-462b-ee8e-08da31d6a1c6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EuL5t3vcxrTOC66ALW8gcR5JQ3XtUnhRQFteRXxAu8l7wONHbxHc7m4Ejpzp5PhAuDRvlM3Z4BlSdutxBWpaHniJXNvzd+e8JyLbGgcwKK0ZZkWp4j6EPzjO4IsGzaCFLkk8QQzx6zhFkkMukCbu8TKCNNwyosl0qezG5RNufGkK8/bYpunB/rxJjx1k/0QjHoFZ0kkc6Hy8+QNOzV5TCRQr0OutI12tq1CWfwKTbju3mCpYharGMgtIrIMSVyDB59TXY0TFj2rFPeO4B629MbOYoyvS8UZhuUFW+vo+X4Z9EmuA20KNVtBLGZQyhRDX4b5cHSXVOWzX6NZ4q44qagXxtAkNIshl8fiNEijqY5PNKlblYK7VKmzwKlq1PK7WnLCjM8PVDNJs6BiCvM2P7aTCBXfvtoRvW1Q4Q6mLNIl+ZddgZGCsxVjJpevttM8P1UEdDbTRwQUpWOue+Zqkkumtv5ErK6UsZtt44V6uk1JtMtFrzrOVkqr1haRVPGMVqCGCK74pkdMGZq9VCyuPyWfZfPNIEJn3CM1risK96U05BlkZ3cZFuxSQg289hBegInnDMDIeUQyog5rYEzhplQyuLsbE1yTJ6uozRik5+c0TcCA6GukYCD/hZ7pzypLDuGDb1xb7c6O1zaN1TKfxYKe7iQjNjEq7XE2FsqSMwQw= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(316002)(70586007)(70206006)(8676002)(4326008)(36860700001)(8936002)(6636002)(55016003)(83380400001)(110136005)(2906002)(6506007)(5660300002)(52536014)(9686003)(40460700003)(26005)(186003)(336012)(33656002)(7696005)(508600001)(47076005)(86362001)(82310400005)(356005)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2022 16:12:06.1976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d741433a-336f-4a10-a37c-08da31d6a97e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4868 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Mon, 09 May 2022 16:12:11 -0000 Improve rematerialization costs of addresses. The current costs are set to= o high=0A= which results in extra register pressure and spilling. Using lower costs m= eans=0A= addresses will be rematerialized more often rather than being spilled or ca= using=0A= spills. This results in significant codesize reductions and performance ga= ins.=0A= SPECINT2017 improves by 0.27% with LTO and 0.16% without LTO. Codesize is = 0.12%=0A= smaller.=0A= =0A= Passes bootstrap and regress. OK for commit?=0A= =0A= ChangeLog:=0A= 2021-06-01 Wilco Dijkstra =0A= =0A= * config/aarch64/aarch64.cc (aarch64_rtx_costs): Use better remater= ialization=0A= costs for HIGH, LO_SUM and SYMREF.=0A= =0A= ---=0A= =0A= diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc= =0A= index 43d87d1b9c4ef1a85094e51f81745f98f1ef27fb..7341849121ffd6b3b0b77c9730e= 74e751742e852 100644=0A= --- a/gcc/config/aarch64/aarch64.cc=0A= +++ b/gcc/config/aarch64/aarch64.cc=0A= @@ -14529,45 +14529,28 @@ cost_plus:=0A= return false; /* All arguments need to be in registers. */=0A= }=0A= =0A= + /* The following costs are used for rematerialization of addresses.=0A= + Set a low cost for all global accesses - this ensures they are=0A= + preferred for rematerialization, blocks them from being spilled=0A= + and reduces register pressure. The result is significant codesize= =0A= + reductions and performance gains. */=0A= +=0A= case SYMBOL_REF:=0A= + *cost =3D 0;=0A= =0A= - if (aarch64_cmodel =3D=3D AARCH64_CMODEL_LARGE=0A= - || aarch64_cmodel =3D=3D AARCH64_CMODEL_SMALL_SPIC)=0A= - {=0A= - /* LDR. */=0A= - if (speed)=0A= - *cost +=3D extra_cost->ldst.load;=0A= - }=0A= - else if (aarch64_cmodel =3D=3D AARCH64_CMODEL_SMALL=0A= - || aarch64_cmodel =3D=3D AARCH64_CMODEL_SMALL_PIC)=0A= - {=0A= - /* ADRP, followed by ADD. */=0A= - *cost +=3D COSTS_N_INSNS (1);=0A= - if (speed)=0A= - *cost +=3D 2 * extra_cost->alu.arith;=0A= - }=0A= - else if (aarch64_cmodel =3D=3D AARCH64_CMODEL_TINY=0A= - || aarch64_cmodel =3D=3D AARCH64_CMODEL_TINY_PIC)=0A= - {=0A= - /* ADR. */=0A= - if (speed)=0A= - *cost +=3D extra_cost->alu.arith;=0A= - }=0A= + /* Use a separate remateralization cost for GOT accesses. */=0A= + if (aarch64_cmodel =3D=3D AARCH64_CMODEL_SMALL_PIC=0A= + && aarch64_classify_symbol (x, 0) =3D=3D SYMBOL_SMALL_GOT_4G)=0A= + *cost =3D COSTS_N_INSNS (1) / 2;=0A= =0A= - if (flag_pic)=0A= - {=0A= - /* One extra load instruction, after accessing the GOT. */=0A= - *cost +=3D COSTS_N_INSNS (1);=0A= - if (speed)=0A= - *cost +=3D extra_cost->ldst.load;=0A= - }=0A= return true;=0A= =0A= case HIGH:=0A= + *cost =3D 0;=0A= + return true;=0A= +=0A= case LO_SUM:=0A= - /* ADRP/ADD (immediate). */=0A= - if (speed)=0A= - *cost +=3D extra_cost->alu.arith;=0A= + *cost =3D COSTS_N_INSNS (3) / 4;=0A= return true;=0A= =0A= case ZERO_EXTRACT:=0A= =0A=