From patchwork Fri Oct 21 13:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RGltaXRyaWplIE1pbG/FoWV2acSH?= X-Patchwork-Id: 6729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp710673wrr; Fri, 21 Oct 2022 06:56:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JDnJriULR5fGnCcvHPLo3T8+ely8gsmjFvZlDWYMvpaJEtT+abAitjc+v+LGkEYuuy6bl X-Received: by 2002:a17:906:4795:b0:794:8b93:2e43 with SMTP id cw21-20020a170906479500b007948b932e43mr10294273ejc.184.1666360575575; Fri, 21 Oct 2022 06:56:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666360575; cv=pass; d=google.com; s=arc-20160816; b=goBRyX2e0HgrM9wjK2/NShZ3mzkuQbUvh7E71ZjK4bHKrfbEIrmiUAhS7+ivfDAex+ EagEZ1eQ+LmCx1f/AwKu7ShWZVgl6BV0BPHPOnk93CwAOc0o5aXDpq8t2rAkNVoS6WjV 6JlaCpwoEFIzcYlkMmKVFqWCtRoVODJd+t4UTUg5SAbA2wlhcoHEGFO1g6oGhy8AlNRA 1M98FeYV+HotAdAmh4vfCn57XJdJ5hgXhAVjEqHcBQ8GPNwD41y1wEi5uRqYcTPLGgJp 5UO/64/JaAr55pQwizfOFccWChGYEpQf49s2sSl7Gt9V9XS3aM4TDQBtBAouhOZnHLfb Xo1A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:dmarc-filter:delivered-to; bh=aIXxHE6n6od9v/yNESc7COqIJl2XI210mA3dBsj3rr8=; b=tixoyyg1PkpeBj5OJrye54zhOs/EPmsJ80ukEFSOvR1ilSVMVu+iCL841pv+a+nhn8 u2uEgmaBA+Np/uKiay94/NkjTEbjyEbMTnDPhFgjl38/G4Id7DDl3B6i0RTpGgvEPFiv /qwvtHGwc1el5mw6sZgvn809pVcN6REh/iie3kBMbK/UPQIt3Q1QbCSkitCqHMteD+qp hxDOKpPF4pRiHQuoF3AtArzRIdU+HLQEZqdeA15TAFWUBIVUUyrFmXskyJSI4BrcgHV+ CKujjVPKwBJeRy8qYGwMIWbCTS5VpvrjUoYQpRVWaQnomUkNBJVn7lEla5Fvo7U+F4bu wxqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@syrmia.com header.s=selector1 header.b=OVkOKfR3; arc=pass (i=1 spf=pass spfdomain=syrmia.com dkim=pass dkdomain=syrmia.com dmarc=pass fromdomain=syrmia.com); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f20-20020a0564021e9400b0045cecdc1fbcsi22513133edf.9.2022.10.21.06.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 06:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@syrmia.com header.s=selector1 header.b=OVkOKfR3; arc=pass (i=1 spf=pass spfdomain=syrmia.com dkim=pass dkdomain=syrmia.com dmarc=pass fromdomain=syrmia.com); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D897C382DB2D for ; Fri, 21 Oct 2022 13:55:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80133.outbound.protection.outlook.com [40.107.8.133]) by sourceware.org (Postfix) with ESMTPS id 0B53D3856974 for ; Fri, 21 Oct 2022 13:54:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0B53D3856974 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Syrmia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NiS7ArjZfj6Ge3KKpd2eSc0H6/g1z50IqfwG1ge9aAFuTOF6RXPlz+2CzUeiHSapjaOxo63BNZt/yJTPxmpa4Qh3hSmnl/o62HXVTFknM6e/WsBFrEVdpkMyUZxOSGL6QPWfb4yrXBYo/lapgnJEWG//7e1QWXPicDwb8d+ZofIRm8CQy4vHTaS8lVAmayRlFgGI9zbH+110+qKvxgdXDV2nga8Q9KobpoTtvzGftcFVMqnW4hnHVtidY6W2njmcQ1jw7mLM0rC4kLa4MLnvWTxyqPDG0uZ9zRXMaJQE5r9xRbJdQPKvAvoIOamNY8J7AkGiH7gay9Pvfme+Tar4qg== 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=aIXxHE6n6od9v/yNESc7COqIJl2XI210mA3dBsj3rr8=; b=dSLMEOb5UeXDmC3+V0quWgqjDRUvWQWs6sQnoy1m95H0JvSxZCZ7EQa0Z3tyMPqmdZLgoCuE+dPCTrZ4A8n/8nwLnRkNPswBaogacljLdUwiEHwq4i6Cf8NuHUt0FH38Jb8ZlPP1pzvtcDdpM1BKd69ATtrw/iS0beJ7YeAXyk67oS5cYCD5JHs1xkUYioTJErrCGuAnrICpieQ8XDNtrgqt0Mw85mh0aRjcIE7vNMMtiplZz0cxLcCS9MzKjuWTQ/1c5t5SFwhypWM/D/dcbvbA6pwZtEMuhQzvj+b0ELlELERKUH+paacGeAver7xRkoK6jWHn43E43SuSKTuZ4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aIXxHE6n6od9v/yNESc7COqIJl2XI210mA3dBsj3rr8=; b=OVkOKfR3eC/cBg1z57zl4VwiccDUcgtLu0Ip3BNsGNEgLHTyxEUZ9BSlaXYhf9kw6TdEkdNNQDxvoAoIyZRRWXtUyxL8pV692jWTSV61tZ2r8mPXkez7CSnkQYSDMCQnRz3hojm80ywTJL+poXpmykRmGRAYd9WjhgeSRcZbA6I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=syrmia.com; Received: from AM0PR03MB4882.eurprd03.prod.outlook.com (2603:10a6:208:fb::17) by VI1PR03MB6189.eurprd03.prod.outlook.com (2603:10a6:800:142::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Fri, 21 Oct 2022 13:54:39 +0000 Received: from AM0PR03MB4882.eurprd03.prod.outlook.com ([fe80::7f26:4554:fc25:8412]) by AM0PR03MB4882.eurprd03.prod.outlook.com ([fe80::7f26:4554:fc25:8412%3]) with mapi id 15.20.5723.035; Fri, 21 Oct 2022 13:54:39 +0000 From: Dimitrije Milosevic To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] ivopts: Revert computation of address cost complexity. Date: Fri, 21 Oct 2022 15:52:02 +0200 Message-Id: <20221021135203.626255-2-dimitrije.milosevic@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021135203.626255-1-dimitrije.milosevic@syrmia.com> References: <20221021135203.626255-1-dimitrije.milosevic@syrmia.com> X-ClientProxiedBy: VE1PR03CA0044.eurprd03.prod.outlook.com (2603:10a6:803:118::33) To AM0PR03MB4882.eurprd03.prod.outlook.com (2603:10a6:208:fb::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR03MB4882:EE_|VI1PR03MB6189:EE_ X-MS-Office365-Filtering-Correlation-Id: 62693db1-6611-47e6-2a69-08dab36bcbcf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OidOZcyaI5/gtVIggdS3pRPt1H7py82dl2ahI4QpUzEJO1p8yQtwSGw7HlORe9FrQS2/h7DxvR1Fg+DDm03z+BFXmvvieJrPmLmHVeB4QuB3TQHUbwG7v1Ln3d8c1HSfJMsVblEqQEwYfKJP9dE57zwkEH5IG7mQ4hBXmiVtzH/cUPuOMPn15I3WqoCAhYN0v0We3QSfsOJh5AHUe5iqdcUPN+zQuXATH1qolQU4qfE2SoAprsZRSS13sfBMUqkejum2v1z+1B8EWAQBMIJwvpUlo2cZXeOmdxAyQcuXpSFHOEXlUBJFF9lqid7rwKSrjRM4h9+0RjoupYr0IaQ2i/+TpAAFUktBAICKXq25EF0uxoTKdGFF7+2SsgpRVM59Gr01RYkQmdwOSWfElbIPNd28jo+a6cM0iQc1rK8YkWQryDBrvWT7oPRpfPtZt0uaU8TNLYyuVbZdN3CAWZM3GJU7iS5QE3cbKM/wRZLZoCYX8uwcme5EvJrdZJJhRS/Qths0anEMFrI/2Asqs73rDluR7XgPIw0uVHDk38mATKffGkEm6HJH+L2+EwUGtonn8hmOrol5zDCCg7+5A19Agt9/lKN8BBJLwcIpklmLi6LefSTSQRdxmx6aH46Hy/YBKRplmgCyBP9rQ0UkH5ZiXbi+a6uHU+Oep5fKYaZ/DF4AAG3PMnhBKAlF0EmJM8zOzmVhmLPeE0BCauCr06xw2PMW/rpIayMI5+sCZsGbBfbfiOOyGxNxHx0q2yItOd5RE6j5gbazxWlvBhwXWC9epg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR03MB4882.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(366004)(39830400003)(376002)(136003)(346002)(396003)(451199015)(66556008)(66946007)(6916009)(44832011)(107886003)(36756003)(41300700001)(26005)(6512007)(52116002)(6506007)(8676002)(66476007)(5660300002)(6666004)(4326008)(8936002)(316002)(2616005)(38350700002)(38100700002)(1076003)(2906002)(186003)(83380400001)(86362001)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?f7ep/xnjgmDDmEgKpjZYYjLb9uNR?= =?utf-8?q?3PiLMTMOGyu0uQxYKmYQFLjUACyxPzBdXKapoOoIQASs/OoFytXjq/ZFWYqEQtvoT?= =?utf-8?q?F41KVrsjoHMe6aYl6vrgeI97Wi4SnUxVtT9/JQuoZMdaFoajl3gX9RKgPvwqt7H/h?= =?utf-8?q?go9i1hS6kWXNTlWYtZhfAbPuvJulpMYrKnedgLQpW/S3/3ohMm6vhqplOcVn2y1Up?= =?utf-8?q?XrugTfkJuXaqDKbNaQQn44mTWiX6YhWYP5pfQW13qIccr8xgHMXQmSl/8sZghwt49?= =?utf-8?q?DpbC+ZUbSeH3kcx1vjJN0C26EgS1Ys+hgA9ufFw0NliBUbF2kwjBOm1OGV1bRxN2o?= =?utf-8?q?46GtbUWGXB92n4hbKJTs8VegpIhK/bheQ5Uz/JbqyFAWf5VXfiTtZiVbvSUq5yAg7?= =?utf-8?q?9YWlZL0JQjwuPORflSqB6XLmlvXaahlj+gb35Pvap4vgoBtwgL6ocqsJD8bRg1Qxx?= =?utf-8?q?wV2wQFL+qJI69HqfiC4ahMLG4ccoAZr+GCFMmQuV+TV5bgUtG6vkIDFZzp+XoyXd4?= =?utf-8?q?USSBImXRMk4tOdayIws/e3rSagGerpMqebSdy2B8ETnk/Z/6lQrXCLLnWnjrIo56B?= =?utf-8?q?6+d4ADho/3DjgjL0sDUrYw96eIGLFvgvCy7z1474ErtEJypMylDt0E36+USW/C7Gz?= =?utf-8?q?VWtaVguFnVKpCqxjFbx4Cmk+z8BluQ/PqSofKGr5qydR2YZCDtMwSWj/RpXh4ROdc?= =?utf-8?q?hrkDjgRSIpvM/OrNmGKNmkGKiRbGi8uC7rBR869ML4mjKvT5oYl27dIT2UGfeL5PA?= =?utf-8?q?/laEptb6k/is0e2b6mvUwtPFSPwnwrOOSpW2W4IRRNT7TFSb3lVbtTZRLR3qz+52Q?= =?utf-8?q?bkZXOi0Uo/3SXQXUmP4xsWohr3YyNz9mx9cftIbC4Zz98DXvAHqPkma4Mq1HBr0g2?= =?utf-8?q?i1twp/cvT+c+gPEwrXPa1lOjuXKkuhBFL7zghX8A0qhQLbfvnB1XQyqCPFF0PC73z?= =?utf-8?q?s5TXAS6/LAXW5EZss93+uXZwjQcYAzM734ZdqQ4cHd/MJED6VquMjz2hDK9JGxzcI?= =?utf-8?q?LjBr4vbTXnWdKdfIYb3CcsoxApTfZF25BpSpxAs7WDPpHF66jaPkujELzOiZFi16G?= =?utf-8?q?NX0CR1tdAaaH7AG5tZrml81oztXFQ4cUaxurCCBSLXO+61i82zML0NAb0nbTeNZVP?= =?utf-8?q?i2+wh6KJRCZ0MPn+F8lsyuTebE45LkBX41KHTsDiEW1wBn0KwJnMTtdUCASBDzrYK?= =?utf-8?q?9oEO1CSAqLxhIuwxdX4T/SsSOiTHmdt+I48UbPj879JFOaKv4jcw1so8x4FaeWW3c?= =?utf-8?q?GU/1gHUArngHgpqPAuazEUWZYdVkEJcMSHlN9vN3FZei540fYvPrObOOeX82fUd0q?= =?utf-8?q?PNX3BRQ20+UjQEDKvIrDC+ZSiAg2c4n0dRbP8SUD24oU/fK1Y3DwDTuVWzi3beUPZ?= =?utf-8?q?6+f3G2hUcPzfjDhxBoC3WBX7e3ldztGNFssIduxChvHlzB/Bp2GsNVBjL6dck4jFF?= =?utf-8?q?TMmHMrhNLXTP3NmvaK6AKT33+Eof+cwD5TZAFZ/Phriy1MEdD1M7JKbBADcdsNBrR?= =?utf-8?q?b5CJ/txsu3SWIsmJVQOACYdp69Jjm/8NWDxFAx9oa2qDbWIbevN1wTg=3D?= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62693db1-6611-47e6-2a69-08dab36bcbcf X-MS-Exchange-CrossTenant-AuthSource: AM0PR03MB4882.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2022 13:54:38.9664 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fctMpf/wpgnu2GwfnFiNXM4M2ecg7yrTl369he4+VwXSepv03om5Js0kWD3gCXeigtx157vY/uto3n9xm1XraqQ+cXnoB2THrXmFY5hn2uA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6189 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: , Cc: =?utf-8?b?RGltaXRyaWplIE1pbG/FoWV2acSH?= , djordje.todorovic@syrmia.com 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?1747305706817589659?= X-GMAIL-MSGID: =?utf-8?q?1747305706817589659?= From: Dimitrije Milošević This patch reverts the computation of address cost complexity to the legacy one. After f9f69dd, complexity is calculated using the valid_mem_ref_p target hook. Architectures like Mips only allow BASE + OFFSET addressing modes, which in turn prevents the calculation of complexity for other addressing modes, resulting in non-optimal candidate selection. gcc/ChangeLog: * tree-ssa-address.cc (multiplier_allowed_in_address_p): Change to non-static. * tree-ssa-address.h (multiplier_allowed_in_address_p): Declare. * tree-ssa-loop-ivopts.cc (compute_symbol_and_var_present): Reintroduce. (compute_min_and_max_offset): Likewise. (get_address_cost): Revert complexity calculation. Signed-off-by: Dimitrije Milosevic --- gcc/tree-ssa-address.cc | 2 +- gcc/tree-ssa-address.h | 2 + gcc/tree-ssa-loop-ivopts.cc | 214 ++++++++++++++++++++++++++++++++++-- 3 files changed, 207 insertions(+), 11 deletions(-) diff --git a/gcc/tree-ssa-address.cc b/gcc/tree-ssa-address.cc index ba7b7c93162..442f54f0165 100644 --- a/gcc/tree-ssa-address.cc +++ b/gcc/tree-ssa-address.cc @@ -561,7 +561,7 @@ add_to_parts (struct mem_address *parts, tree elt) validity for a memory reference accessing memory of mode MODE in address space AS. */ -static bool +bool multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, machine_mode mode, addr_space_t as) { diff --git a/gcc/tree-ssa-address.h b/gcc/tree-ssa-address.h index 95143a099b9..09f36ee2f19 100644 --- a/gcc/tree-ssa-address.h +++ b/gcc/tree-ssa-address.h @@ -38,6 +38,8 @@ tree create_mem_ref (gimple_stmt_iterator *, tree, class aff_tree *, tree, tree, tree, bool); extern void copy_ref_info (tree, tree); tree maybe_fold_tmr (tree); +bool multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, machine_mode mode, + addr_space_t as); extern unsigned int preferred_mem_scale_factor (tree base, machine_mode mem_mode, diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc index a6f926a68ef..d53ba05a4f6 100644 --- a/gcc/tree-ssa-loop-ivopts.cc +++ b/gcc/tree-ssa-loop-ivopts.cc @@ -4774,6 +4774,135 @@ get_address_cost_ainc (poly_int64 ainc_step, poly_int64 ainc_offset, return infinite_cost; } +static void +compute_symbol_and_var_present (tree e1, tree e2, + bool *symbol_present, bool *var_present) +{ + poly_uint64_pod off1, off2; + + e1 = strip_offset (e1, &off1); + e2 = strip_offset (e2, &off2); + + STRIP_NOPS (e1); + STRIP_NOPS (e2); + + if (TREE_CODE (e1) == ADDR_EXPR) + { + poly_int64_pod diff; + if (ptr_difference_const (e1, e2, &diff)) + { + *symbol_present = false; + *var_present = false; + return; + } + + if (integer_zerop (e2)) + { + tree core; + poly_int64_pod bitsize; + poly_int64_pod bitpos; + widest_int mul; + tree toffset; + machine_mode mode; + int unsignedp, reversep, volatilep; + + core = get_inner_reference (TREE_OPERAND (e1, 0), &bitsize, &bitpos, + &toffset, &mode, &unsignedp, &reversep, &volatilep); + + if (toffset != 0 + || !constant_multiple_p (bitpos, BITS_PER_UNIT, &mul) + || reversep + || !VAR_P (core)) + { + *symbol_present = false; + *var_present = true; + return; + } + + if (TREE_STATIC (core) + || DECL_EXTERNAL (core)) + { + *symbol_present = true; + *var_present = false; + return; + } + + *symbol_present = false; + *var_present = true; + return; + } + + *symbol_present = false; + *var_present = true; + } + *symbol_present = false; + + if (operand_equal_p (e1, e2, 0)) + { + *var_present = false; + return; + } + + *var_present = true; +} + +static void +compute_min_and_max_offset (addr_space_t as, + machine_mode mem_mode, poly_int64_pod *min_offset, + poly_int64_pod *max_offset) +{ + machine_mode address_mode = targetm.addr_space.address_mode (as); + HOST_WIDE_INT i; + poly_int64_pod off, width; + rtx addr; + rtx reg1; + + reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1); + + width = GET_MODE_BITSIZE (address_mode) - 1; + if (known_gt (width, HOST_BITS_PER_WIDE_INT - 1)) + width = HOST_BITS_PER_WIDE_INT - 1; + gcc_assert (width.is_constant ()); + addr = gen_rtx_fmt_ee (PLUS, address_mode, reg1, NULL_RTX); + + off = 0; + for (i = width.to_constant (); i >= 0; i--) + { + off = -(HOST_WIDE_INT_1U << i); + XEXP (addr, 1) = gen_int_mode (off, address_mode); + if (memory_address_addr_space_p (mem_mode, addr, as)) + break; + } + if (i == -1) + *min_offset = 0; + else + *min_offset = off; + // *min_offset = (i == -1? 0 : off); + + for (i = width.to_constant (); i >= 0; i--) + { + off = (HOST_WIDE_INT_1U << i) - 1; + XEXP (addr, 1) = gen_int_mode (off, address_mode); + if (memory_address_addr_space_p (mem_mode, addr, as)) + break; + /* For some strict-alignment targets, the offset must be naturally + aligned. Try an aligned offset if mem_mode is not QImode. */ + off = mem_mode != QImode + ? (HOST_WIDE_INT_1U << i) + - (GET_MODE_SIZE (mem_mode)) + : 0; + if (known_gt (off, 0)) + { + XEXP (addr, 1) = gen_int_mode (off, address_mode); + if (memory_address_addr_space_p (mem_mode, addr, as)) + break; + } + } + if (i == -1) + off = 0; + *max_offset = off; +} + /* Return cost of computing USE's address expression by using CAND. AFF_INV and AFF_VAR represent invariant and variant parts of the address expression, respectively. If AFF_INV is simple, store @@ -4802,6 +4931,13 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, /* Only true if ratio != 1. */ bool ok_with_ratio_p = false; bool ok_without_ratio_p = false; + tree ubase = use->iv->base; + tree cbase = cand->iv->base, cstep = cand->iv->step; + tree utype = TREE_TYPE (ubase), ctype; + unsigned HOST_WIDE_INT cstepi; + bool symbol_present = false, var_present = false, stmt_is_after_increment; + poly_int64_pod min_offset, max_offset; + bool offset_p, ratio_p; if (!aff_combination_const_p (aff_inv)) { @@ -4915,16 +5051,74 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, gcc_assert (memory_address_addr_space_p (mem_mode, addr, as)); cost += address_cost (addr, mem_mode, as, speed); - if (parts.symbol != NULL_TREE) - cost.complexity += 1; - /* Don't increase the complexity of adding a scaled index if it's - the only kind of index that the target allows. */ - if (parts.step != NULL_TREE && ok_without_ratio_p) - cost.complexity += 1; - if (parts.base != NULL_TREE && parts.index != NULL_TREE) - cost.complexity += 1; - if (parts.offset != NULL_TREE && !integer_zerop (parts.offset)) - cost.complexity += 1; + if (cst_and_fits_in_hwi (cstep)) + cstepi = int_cst_value (cstep); + else + cstepi = 0; + + STRIP_NOPS (cbase); + ctype = TREE_TYPE (cbase); + + stmt_is_after_increment = stmt_after_increment (data->current_loop, cand, + use->stmt); + + if (cst_and_fits_in_hwi (cbase)) + compute_symbol_and_var_present (ubase, build_int_cst (utype, 0), + &symbol_present, &var_present); + else if (ratio == 1) + { + tree real_cbase = cbase; + + /* Check to see if any adjustment is needed. */ + if (!cst_and_fits_in_hwi (cstep) && stmt_is_after_increment) + { + aff_tree real_cbase_aff; + aff_tree cstep_aff; + + tree_to_aff_combination (cbase, TREE_TYPE (real_cbase), + &real_cbase_aff); + tree_to_aff_combination (cstep, TREE_TYPE (cstep), &cstep_aff); + + aff_combination_add (&real_cbase_aff, &cstep_aff); + real_cbase = aff_combination_to_tree (&real_cbase_aff); + } + compute_symbol_and_var_present (ubase, real_cbase, + &symbol_present, &var_present); + } + else if (!POINTER_TYPE_P (ctype) + && multiplier_allowed_in_address_p + (ratio, mem_mode, + TYPE_ADDR_SPACE (TREE_TYPE (utype)))) + { + tree real_cbase = cbase; + + if (cstepi == 0 && stmt_is_after_increment) + { + if (POINTER_TYPE_P (ctype)) + real_cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep); + else + real_cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep); + } + real_cbase = fold_build2 (MULT_EXPR, ctype, real_cbase, + build_int_cst (ctype, ratio)); + compute_symbol_and_var_present (ubase, real_cbase, + &symbol_present, &var_present); + } + else + { + compute_symbol_and_var_present (ubase, build_int_cst (utype, 0), + &symbol_present, &var_present); + } + + compute_min_and_max_offset (as, mem_mode, &min_offset, &max_offset); + offset_p = maybe_ne (aff_inv->offset, 0) + && known_le (min_offset, aff_inv->offset) + && known_le (aff_inv->offset, max_offset); + ratio_p = (ratio != 1 + && multiplier_allowed_in_address_p (ratio, mem_mode, as)); + + cost.complexity = (symbol_present != 0) + (var_present != 0) + + offset_p + ratio_p; return cost; } From patchwork Fri Oct 21 13:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RGltaXRyaWplIE1pbG/FoWV2acSH?= X-Patchwork-Id: 6731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp711147wrr; Fri, 21 Oct 2022 06:57:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4PKI925Uha9IQDC4Ps79W2ucUjvTnpkQ7dBCrxYdp4H8oU+Mn0VsUd8gpyE74cxZ0/tF0r X-Received: by 2002:a17:906:794b:b0:790:2dc7:3115 with SMTP id l11-20020a170906794b00b007902dc73115mr15810677ejo.3.1666360652599; Fri, 21 Oct 2022 06:57:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666360652; cv=pass; d=google.com; s=arc-20160816; b=Z1lhJs9x6EGTXxEivp9qiQ5bnNruKH1tu83d4v6BaK9NlyiwK+GYmjzGgIWr1BZosI AdMnAFito9XKCNmyX9QcuAz/vDT/g52dJBBtrbe24AJ++X+EDRW9PcDlW741pL0s5khP XISKcQAuyB5K8NFsprFw6H+n1gaOh+dsBtQioR6dsiMDHEH7uMheMBxKXiWVng8r/mun yTTvDYu81ZJphPBDj+l6yn65NnTztoT05Rteoelc36o81vOihpglcGV7W4Y59kFvtzvt JnX4VPtXKpC+r8OgaRGPCzeDL2bhpZBr53EELgIpmrJ6EbK7iCNC5YGIxcwDy1zpPB8K TMQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:dmarc-filter:delivered-to; bh=PZGw1ZHzNkNmtVkTWP130bBPAUVaiGMf1hlysVd4aoA=; b=hnaq9B9p0r13A8AmcmXfJq4Pe9GS5ehegk5AGEI9eMeNPJOXZak3ZIsM4Ee6hfb09C FSpQROpL2Zwcn9mzys2aJMYzguqb1pZ0I7Yeg96eEuts79k/Lfs8NgQAvUjCmLlxx+nl BcLUv7JKFG2krWiVUFW4MJ+6R9RACpIlysFuJM5tHQMzurYQYu6LZh+Oo2aE5QHRSI+5 4zJFL3W9FIFQChLWYynba6py6UR4Fd0Bq3Ha8rk9XJmN0OAM3qe1qwu94sU2mELU+gZi FbTUZ8oI2+l54X6aRRY5/BBnHF58wShAExbVu61l0sikKzZd9tBeush2tH1DSNrqFd9m npaA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@syrmia.com header.s=selector1 header.b=LHCdaU0P; arc=pass (i=1 spf=pass spfdomain=syrmia.com dkim=pass dkdomain=syrmia.com dmarc=pass fromdomain=syrmia.com); 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" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gm1-20020a1709073d0100b0073da19d0cdasi7197491ejc.973.2022.10.21.06.57.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 06:57:32 -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=@syrmia.com header.s=selector1 header.b=LHCdaU0P; arc=pass (i=1 spf=pass spfdomain=syrmia.com dkim=pass dkdomain=syrmia.com dmarc=pass fromdomain=syrmia.com); 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD6BC3851148 for ; Fri, 21 Oct 2022 13:55:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80133.outbound.protection.outlook.com [40.107.8.133]) by sourceware.org (Postfix) with ESMTPS id 43EF9385354F for ; Fri, 21 Oct 2022 13:54:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 43EF9385354F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=syrmia.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Syrmia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fW8YV2B1CIT2TOnQNpCEYtFFFjyYal1hmJ6bU+dsuPMPaaXj5v7YIQb+WeialhwlmDxKXrPbv0d6JxlP5mKXhdZrn16oFdko8cMawTRrXpR9wl2Dz9FlF649Injj5iCOPp3eP4yO2Q0AfSJo6Kl5ZPjmDgHrvUSgz4byMOeaktuXh96jwcWJxYrzKxaBLokhH3TvWNrigskSc1kmMF5ruXOW/CUD9Ky8HCanl/uzt2zufWxT5AEst6gCd27WUpzEczFX2MIOkh5UQ9wJmTxMly3HXUX15SSd4w0l1A2Y65Rh5meYAbGccoU393rs/qY6+bDqFJ/rcJj9PG+v09iexw== 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=PZGw1ZHzNkNmtVkTWP130bBPAUVaiGMf1hlysVd4aoA=; b=Zrc9EzE/M6pM/fM/rSFN4fUdAZNVgP2ukYq6A2yxGnodDV38BMBaNAakclOANutCo783yscZsKeTBsjuzS/iOIvxHIctHM1o0hwK36TikCN2vgevQ9QDQCfDwVS06NXA8vPhofC+tyVgCGJLkg2hrw/tWGMTQpsznwzfG+Uf3CO4uBfao/mNJ7JFvl4HaszwcyJ3rFOsUU1t7PY3NngkzfezYNP0/XmMgh1NnbNzMDaD/zyJ79UA4AoSg5U8PP3HLS1Y+i2h/SRHmZ+3MM74qh5/aRM310ezXhZRWUOQi3wvhvvAhJVZW1u/ON4plJFAKOugi4VOW/nSRsJHmZ9RkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PZGw1ZHzNkNmtVkTWP130bBPAUVaiGMf1hlysVd4aoA=; b=LHCdaU0PlsrAWjJ6BvlbOXPbzFkgr85Y1vNYhJJOVkLPXEmQ25LtzucIzYgnxY6LqB+2hkNj515vmtlIpqBQsKml/mIl8kQRVT90BjQM8oyJfZMx7KSP4Ak47Tnovl/7ANtSR8Gqsri7SJ/hFM1t9DdzqToO1cp/CKmnQ2g5K2k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=syrmia.com; Received: from AM0PR03MB4882.eurprd03.prod.outlook.com (2603:10a6:208:fb::17) by VI1PR03MB6189.eurprd03.prod.outlook.com (2603:10a6:800:142::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Fri, 21 Oct 2022 13:54:40 +0000 Received: from AM0PR03MB4882.eurprd03.prod.outlook.com ([fe80::7f26:4554:fc25:8412]) by AM0PR03MB4882.eurprd03.prod.outlook.com ([fe80::7f26:4554:fc25:8412%3]) with mapi id 15.20.5723.035; Fri, 21 Oct 2022 13:54:40 +0000 From: Dimitrije Milosevic To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] ivopts: Consider number of invariants when calculating register pressure. Date: Fri, 21 Oct 2022 15:52:03 +0200 Message-Id: <20221021135203.626255-3-dimitrije.milosevic@syrmia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021135203.626255-1-dimitrije.milosevic@syrmia.com> References: <20221021135203.626255-1-dimitrije.milosevic@syrmia.com> X-ClientProxiedBy: VE1PR03CA0044.eurprd03.prod.outlook.com (2603:10a6:803:118::33) To AM0PR03MB4882.eurprd03.prod.outlook.com (2603:10a6:208:fb::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR03MB4882:EE_|VI1PR03MB6189:EE_ X-MS-Office365-Filtering-Correlation-Id: f289310e-99d8-4c2c-1e76-08dab36bcc89 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t9L3CV8s6CHS8pwxEnXgbbhLE1p/LPLO0UjKaaY8KPlEkFsO8gOLepwT3PIE7J8MlbEJRKackEL/AdJIt34AInITTE2BaftxCue5khs5IFpSgYG7oDcMYgQjqeLEMp/3PHaGKs/oo9Mf9XdGPR3VD6LxQPhtqNOUHBJkcLdTuLRPYbSC3OtxT1QMc4A/KN70I6kAruyx/mo1Zax/pzUIECBkJZj96si+DTa+74oZxXC8+Miq+oCfkU3m/6QlYslddao/vITxFv5jsGU7iYXxjwwsDFtJefbV8E734IPVGbxmQ0Q40EPjP4arTZoExMJSFmOMz5ccIVMPv0QWTNz7m8AjH9f9nkvPhFLtMwTSKc/yfx+Gc94fPlHVrafNlPeRfPogqsDTjxxxTh1+NDGmNaAIkhKJa/fTOgv5L0wgXY2R2eUJB0pJyGOZ1XE2KWI+qDV3GF+L8CyDcsD7m+dryk3AiB0R0M7fx4/1VKsCK0XM8erlxLvwjAXYEKC7/inDDN6soLBiYYboYoDk/uDlOTdP6tHGbXn+gg8SE+1dJzu6JGfrUVb+m8PU9efbj7nGmHXxyoTV+I1DwYYwng2TweLjOR7MPzMwhM5ftoQar/erBE3BUeF6RCuTVvuU5KCD/uFo4ulfczwqHm+ex3cJce0P07PcwRs2OYJ5kvfAh0RgUyponJ17OaB5iu/D82jjCQqDA4rHGFwe9fj1FSQz7ag1EjXHPoZ8wV5zXxAYAEByPiLnWn3A2wSuLRwM5vcVLMOyA96nNAbC+oR3OVG7pQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR03MB4882.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(366004)(39830400003)(376002)(136003)(346002)(396003)(451199015)(66556008)(66946007)(6916009)(44832011)(107886003)(36756003)(41300700001)(26005)(6512007)(52116002)(6506007)(8676002)(66476007)(5660300002)(6666004)(4326008)(8936002)(316002)(2616005)(38350700002)(38100700002)(1076003)(2906002)(186003)(83380400001)(86362001)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?33vDev3sBRVjphCXeEO7UJYcQ5MU?= =?utf-8?q?mpN3gXTSVKp6HXyQNisCtaW/4w6A9PsD+sTTQoFG7EAFWxxqaeF3mZfM+nJPPf+aj?= =?utf-8?q?5/pN/74L78iwWCCpi/2qVftZp1LEfjj4FezTHqPtAbGXE9fQPgKinDXuULAn7QvzG?= =?utf-8?q?82TUyy8vHZq0kkbm1BzY6xtsB0PT/st8y9WNmBSjgbJJRlZotOETKXEG8YUpVZlev?= =?utf-8?q?pNJkGmbZHf2KEfffSrS3oQJGXw0q1CxIln5PWtAFk6hQaio5vYguCGvZZA/kgucSl?= =?utf-8?q?rAhRJF3z8UIPvD6tSHopJrzdSc5jKvxR2Nh8JD0kkGAgkUYIUhuuNnIg6Zq18v0+l?= =?utf-8?q?NNC2tYSfgqboAxiaJLIG++iS7xZIvVZx4AkugUVu8gSu3vXqf2sKOyzNnwtIII3Zd?= =?utf-8?q?vq6ie8xyeql0QbOZ01P+Zy96XaAuZPy4k0NdBB9TBB60X2CeoCg7BJoMv/NYgUFrf?= =?utf-8?q?wgxbwx27w8arFpvgUatirUKgYkiBRoNg1LTJH8L3YpoVpVDaZROxtTMrn9/r1zNXu?= =?utf-8?q?0H9sOd1JK4v6WWljBzwoseG24q7/B52ivtUb5w4pWLsnW/cEz7s1zuV9e9bIXr7dK?= =?utf-8?q?79AHyigpNFT7VIdyFDXp846wBYxME2h7xqyxP9Ikzb2VdJYkM8trfgfpzLjTgd9az?= =?utf-8?q?ND1Cy8jbfZuZ1Ar3bPFOVXnZsmQt8D78fx3CrT8bdBzwJPjCJu7NOvjevsfLnrYwb?= =?utf-8?q?ZEn+inJRuWMmoCoEOuQt55fZlElXVl1LXvDA3GV4fp2A+PUJDG0nBqJwVKPwzhGfp?= =?utf-8?q?/zueeERF3uUDT0pMsHQA7YkIjOyN3rtzesKIk84PslqryrzzR27F3XVXZLojej84H?= =?utf-8?q?btZiShVYM0vUwvz23bWEUXEq1vmxSAHa1tAQM0ZPAHFSRyJ/VeE5lREu5Udkf8Pvg?= =?utf-8?q?1mkklc3bSpovp2g4BVQROVyoR3GghCxnwitz+TKg9Vpy3FSbuq6hTG3Od8gZyapqi?= =?utf-8?q?H7r9bJwuED3X2ved5Z8bd3KDobaPQ7bguQeQ+AbE1w0oDUr0OQZRr42aOyjBkbAdM?= =?utf-8?q?0CKcANRYljOSBJ9R2j8hr/glrdH/Bh05u2mRliWzaD8kY0bx1nyW1DJuxxW7RVsHS?= =?utf-8?q?maILrMK8pvXz3HQ4+HEukA6nWp6UEMwX2DTQyqt+bfFe5gf1TsqmZR9gManj1wx0F?= =?utf-8?q?Sep4xZk+nDPDSosUf3AyrCOO7043P8Wn/PPEKTtebTp2hNmTfN5UzeZ5Vg+qx1gGN?= =?utf-8?q?WotnzIkbA7F4Udm2N3Yurz6j66g2OmPEEWd/UbPGfOT1Dz59QhCkuMHdrC9xev9vB?= =?utf-8?q?04o5OoLCqzME74hPILhh5OXUfJ04qy7DlxJGxWjj1gSD+31VwW/IxliF99uAKGvK+?= =?utf-8?q?2gGLZsd0TKoX2cCcpJ8J/9j5e7REaiTGpKarwT6WYof4kp6k3agbq6BZ6tOb7U/S2?= =?utf-8?q?RA4lvTRXTlh5Rw01BGgBaIDPjqLoLy0d6iVEANEObFTTTXZB7q7kRNsyhcE4f7v7+?= =?utf-8?q?cs07vgPRZ0BWGt/cxz8vGxxxeKc8xH7rvdEbICeBq4GJrd8AIF/vCgnt2CHHo5fAx?= =?utf-8?q?joBY6SnQ3gHPxb/XAcFsIK5Z312d0bRwZnaeGbWO7G2yUTBLrSvZurs=3D?= X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f289310e-99d8-4c2c-1e76-08dab36bcc89 X-MS-Exchange-CrossTenant-AuthSource: AM0PR03MB4882.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2022 13:54:40.2319 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: drSWoQf9l8O9bSntY9iABNiPMNas6oTFdNl4Outmu02ybWQq4ct2KA05MBIosn9qRrHGxCv8twWec6Qk3sZ5pip1W8WSg6zp1GJOCFQZuIc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR03MB6189 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: , Cc: =?utf-8?b?RGltaXRyaWplIE1pbG/FoWV2acSH?= , djordje.todorovic@syrmia.com 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?1747305787452418385?= X-GMAIL-MSGID: =?utf-8?q?1747305787452418385?= From: Dimitrije Milošević This patch slightly modifies register pressure model function to consider both the number of invariants and the number of candidates, rather than just the number of candidates. This used to be the case before c18101f. gcc/ChangeLog: * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure): Adjust. Signed-off-by: Dimitrije Milosevic --- gcc/tree-ssa-loop-ivopts.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc index d53ba05a4f6..9d0b669d671 100644 --- a/gcc/tree-ssa-loop-ivopts.cc +++ b/gcc/tree-ssa-loop-ivopts.cc @@ -6409,9 +6409,9 @@ ivopts_estimate_reg_pressure (struct ivopts_data *data, unsigned n_invs, + target_spill_cost [speed] * (n_cands - available_regs) * 2 + target_spill_cost [speed] * (regs_needed - n_cands); - /* Finally, add the number of candidates, so that we prefer eliminating - induction variables if possible. */ - return cost + n_cands; + /* Finally, add the number of invariants and the number of candidates, + so that we prefer eliminating induction variables if possible. */ + return cost + n_invs + n_cands; } /* For each size of the induction variable set determine the penalty. */