From patchwork Tue Apr 18 11:43:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Do Nascimento X-Patchwork-Id: 84779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2778303vqo; Tue, 18 Apr 2023 04:44:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ZGHu+2zw1boHj+zabDsH6hGQ6rc+2K4/vXu1f5dy3kQLGQMOunvKjZsUIdQANLX3v+2Vs5 X-Received: by 2002:a17:906:1f56:b0:94f:5847:8ac with SMTP id d22-20020a1709061f5600b0094f584708acmr7876861ejk.51.1681818281096; Tue, 18 Apr 2023 04:44:41 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id mf7-20020a1709071a4700b0094f006493efsi7401981ejc.867.2023.04.18.04.44.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 04:44:41 -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=@gcc.gnu.org header.s=default header.b=KeJ0gmuj; arc=fail (signature failed); 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"; 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 E32D13858C74 for ; Tue, 18 Apr 2023 11:44:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E32D13858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681818279; bh=CYRcCIBXO7Q/dlsOK/4poy6b1ZfqbrEAPPZJfP69d+0=; h=Date:To:CC:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=KeJ0gmujlLWXWuPZcxxET2BKjlhv/hVlqLqxCZfFMvU8WE1G+uDEW28e07Y4XM5UH r19pRTLS3NiQc29C2VSQ7btN6aNA03J7ts1bIhxtjSseo2G9JZOh0mEQFSoFZfnxp1 Glp+EBD1iNB+fzzKK18NO4iT2SyqkfSro3eQ68gw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2074.outbound.protection.outlook.com [40.107.6.74]) by sourceware.org (Postfix) with ESMTPS id 5A85F3858D1E for ; Tue, 18 Apr 2023 11:43:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5A85F3858D1E Received: from DUZPR01CA0259.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b9::7) by DU0PR08MB9080.eurprd08.prod.outlook.com (2603:10a6:10:474::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Tue, 18 Apr 2023 11:43:51 +0000 Received: from DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b9:cafe::de) by DUZPR01CA0259.outlook.office365.com (2603:10a6:10:4b9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.47 via Frontend Transport; Tue, 18 Apr 2023 11:43:51 +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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT056.mail.protection.outlook.com (100.127.142.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.20 via Frontend Transport; Tue, 18 Apr 2023 11:43:51 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 18 Apr 2023 11:43:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d30b3c7b164563aa X-CR-MTA-TID: 64aa7808 Received: from 098359882b7c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 01625967-5419-42CE-BD64-BF70951EDD37.1; Tue, 18 Apr 2023 11:43:44 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 098359882b7c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 Apr 2023 11:43:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQviSMn9S9LJ3oXopW1I7B1cBH05qMC84BwNY8aIu7xt9wF1PJOXxP+abVJPzK0M0ldNQZW8IGcmrl2lK035k/B0rFFBIJUvuGXh35GL3M81VFeJkRJCZ3W+T+jxmiA5B3ZEEH/HzE6xpcv8nUQ9OlM9rd3ZK0trPVuLqMRfw2DA3qMmSTU5sZlvbH46PmPwMKHDa7MLvLAclIl/v3jtRanvO2ODjqy6HqO8EGCd7ighyEFxfX2+BDr/MUiLmfNwgCaLDjK9XRh23Ewvp7i0M+tH0KgUVUFEaSQYJGoIiPwmcfY0HcsqPxsq6PA0lEYx9WjvNaX1ryiaZ2ayhfx9fw== 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=CYRcCIBXO7Q/dlsOK/4poy6b1ZfqbrEAPPZJfP69d+0=; b=VYJ83Ocp4TfBXEOJfiXQarQJTf0OSwqC+80dI6fKiAt9h+F5XdOWi73yoAe7iCNQely+yX1zkpjsJlpIqLUlqRlMr5dof+KkM0VJMyWVrXvP3n5w4pkxvyCurySLRfhCfmDmI5YbKZEQ+1eAgpX5Hc7f0Nbjcw8MslvEFWRaM1OtXWLhpbXodc1RttVsPEK+1ST/PCDKarbjFhkwQCfxIaua+S2b8Unp+dd4oHYV44uFep7KUZODHtZ1aHj0v2oHik0E1yBDtxxIpJoLNLbAzvW97u+UGoDkgvaamQtGPpzLSz14NOB+sa/FOvrNflY3gHgyQBUfpJxqmmQcQ+ymIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from DB6P195CA0023.EURP195.PROD.OUTLOOK.COM (2603:10a6:4:cb::33) by AS8PR08MB6023.eurprd08.prod.outlook.com (2603:10a6:20b:291::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Tue, 18 Apr 2023 11:43:43 +0000 Received: from DBAEUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:cb:cafe::64) by DB6P195CA0023.outlook.office365.com (2603:10a6:4:cb::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Tue, 18 Apr 2023 11:43:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT058.mail.protection.outlook.com (100.127.142.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.20 via Frontend Transport; Tue, 18 Apr 2023 11:43:42 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 18 Apr 2023 11:43:41 +0000 Received: from e125768 (10.2.78.50) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Tue, 18 Apr 2023 11:43:41 +0000 Date: Tue, 18 Apr 2023 12:43:41 +0100 Message-ID: To: CC: , Subject: [PATCH v3] constraint: fix relaxed memory and repeated constraint handling MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT058:EE_|AS8PR08MB6023:EE_|DBAEUR03FT056:EE_|DU0PR08MB9080:EE_ X-MS-Office365-Filtering-Correlation-Id: d091bfdc-3f9d-4538-c71f-08db40022ea1 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: Dg7ALiM4oomTGqmZflnmNudAKzGu4bq0GITyg9lqqWV4zZHDsow2UWD5aAZrMz5ZPHKc7KAFpAo43uEG2IJ0QZxPELGDI0PzOYoZbXX6cG43MEihUdnE30sDTU/oITSRzQOjHiVFqm8ctutsCtLrubsNbCGaZMyF2y6C15twOGE9EzR7BdoH2nDWG5wL8X/QMJriQFKem9qhP438724CLZWD5Kk0yQY7TTa155RPD2x6gUyBlSOj5bEZwO+COLZvxxp5DWtqvxgu2pry+Y9vbwaKRhId1qenvZKgeb5eAiu3ZSqnxXcNYxhqjZaXD5g1x6bUvBTDrmR8MVg1+MeZKnaZt0cdwRdi0caCgufZjIcYY2C1F5iN5xWoEyP82jwvXQmg4q2CqpQpWqGfkNbd39TctMjxIKfryGrwRXAs1BqswBfMc+caDE4jLXs1U7UfRNMIXh8SMwiJgaNjkH4PJ78ft3smBeFhry4hh1Az2aT0xC3n9dpCLnmSIVFgkaUuqcg+YgnGaWUz8SfQcfkRVKkEpMRTMlK9+3MyO2nvtUVpElLlcKGUwkZikAPpOD25gRXWoISRLj/Os7cetfudIRq8SHWqCgbKZVy9MqEhWUbAhMvJ/AWYxxT/y6YCq/oPLRFZIpyWoX0zrvM6a93eEm/9dq87+dAaWc75y69BvvYAwhuUUmyplDNsc3TYoQBJxE3JkVRZ84jhle0vocZISQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199021)(46966006)(36840700001)(36756003)(4326008)(6916009)(54906003)(316002)(70586007)(70206006)(478600001)(41300700001)(5660300002)(82310400005)(8676002)(8936002)(40480700001)(2906002)(82740400003)(86362001)(81166007)(356005)(426003)(2616005)(336012)(26005)(186003)(36860700001)(47076005)(83380400001)(66899021)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6023 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 06fce28b-2f18-4f2c-1eef-08db40022934 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lH9olaoBZFedkiCGYtrs2dNnTEs4oixUnSTWi0INQyqLTca/B9vU1Q3hqahjJryJN+hHARx2zEvrcilsBVvMtF6b4bZTNozgR25mvOameLnzN80IopZe6nTzbFF75GPTM/KaBNd7lgnlxK1vfYfPRiB0P/wUfNfXznLspnYEe+0LMJFNzTOQxUItQWRYPlo/f6F7ZYsP21yEJb7NOeV7LI4Cg56w1fdzUZL0S+I8KS/xDLoyetXzh7NPEH7Veza4C7oWn/SWVTWgXoDN8UTd4y3G8IhxhNAs89o9C275n58+bLgMz+aVp5JVmv9josW9Dtj+5d7/ep9p4wYGbeAAp1aGh5GDntLkrIfk5cl//jj2Vyq6gFvUvMBaJk27b75kjddTxMgkWPsGdDWZ8tgTBadKyu3XKba0ketptMIruUkcxtP3Qiat8hBeTa1n8musE1FjZynuSpeQU6hwepXW7excfn6+M51jH6ijRDCuX//Fl0dZ+K55kpaIjNgEbYOPw2NcZJf+qrnkwN7cbYoyUV+tR+rZ0tB9qtPP7uuWOJfqS+/HiucaX7VfIU9pd+k1BIYbLxO5e0COulhWbYpckKMe4yqJV88DIQpkcI/KtdixzxSQK2MPwfqF3KmB8yoy60dgaiY+9fgbYJSgd6ndlPcNv9qM06bFkDaYtxN9GjBQ+WSApsSm615BaPHNTkYVcP69CLP8TA7Bj/SwBgzqsA== 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:(13230028)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199021)(40470700004)(46966006)(36840700001)(8676002)(478600001)(8936002)(66899021)(316002)(41300700001)(82740400003)(6916009)(4326008)(70586007)(70206006)(40480700001)(81166007)(54906003)(40460700003)(186003)(2906002)(36756003)(26005)(336012)(86362001)(83380400001)(426003)(82310400005)(47076005)(36860700001)(5660300002)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2023 11:43:51.9367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d091bfdc-3f9d-4538-c71f-08db40022ea1 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: DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9080 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY 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: "Victor L. Do Nascimento via Gcc-patches" From: Victor Do Nascimento Reply-To: "Victor L. Do Nascimento" 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?1763508641517998709?= X-GMAIL-MSGID: =?utf-8?q?1763514286178386870?= The function `constrain_operands' lacked the logic to consider relaxed memory constraints when "traditional" memory constraints were not satisfied, creating potential issues as observed during the reload compilation pass. In addition, it was observed that while `constrain_operands' chooses to disregard constraints when more than one alternative is provided, e.g. "m,r" using CONSTRAINT__UNKNOWN, it has no checks in place to determine whether the multiple constraints in a given string are in fact repetitions of the same constraint and should thus in fact be treated as a single constraint, as ought to be the case for something like "m,m". Both of these issues are dealt with here, thus ensuring that we get appropriate pattern matching. Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? Victor gcc/ * lra-constraints.cc (constraint_unique): New. (process_address_1): Apply constraint_unique test. * recog.cc (constrain_operands): Allow relaxed memory constaints. --- gcc/lra-constraints.cc | 39 ++++++++++++++++++++++++++++++++++++--- gcc/recog.cc | 3 ++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index dd4f68bbfc0..a210d6e0697 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -3448,6 +3448,41 @@ skip_constraint_modifiers (const char *str) } } +/* Takes a string of 0 or more comma-separated constraints. When more + than one constraint is present, evaluate whether they all correspond + to a single, repeated constraint (e.g. "r,r") or whether we have + more than one distinct constraints (e.g. "r,m"). */ +static bool +constraint_unique (const char *cstr) +{ + enum constraint_num ca, cb; + ca = CONSTRAINT__UNKNOWN; + for (;;) + { + cstr = skip_constraint_modifiers (cstr); + if (*cstr == '\0' || *cstr == ',') + cb = CONSTRAINT_X; + else + { + cb = lookup_constraint (cstr); + if (cb == CONSTRAINT__UNKNOWN) + return false; + cstr += CONSTRAINT_LEN (cstr[0], cstr); + } + /* Handle the first iteration of the loop. */ + if (ca == CONSTRAINT__UNKNOWN) + ca = cb; + /* Handle the general case of comparing ca with subsequent + constraints. */ + else if (ca != cb) + return false; + if (*cstr == '\0') + return true; + if (*cstr == ',') + cstr += 1; + } +} + /* Major function to make reloads for an address in operand NOP or check its correctness (If CHECK_ONLY_P is true). The supported cases are: @@ -3507,9 +3542,7 @@ process_address_1 (int nop, bool check_only_p, operand has one address constraint, probably all others constraints are address ones. */ if (constraint[0] != '\0' && get_constraint_type (cn) != CT_ADDRESS - && *skip_constraint_modifiers (constraint - + CONSTRAINT_LEN (constraint[0], - constraint)) != '\0') + && !constraint_unique (constraint)) cn = CONSTRAINT__UNKNOWN; if (insn_extra_address_constraint (cn) /* When we find an asm operand with an address constraint that diff --git a/gcc/recog.cc b/gcc/recog.cc index 200cf4214f1..3ddeab59d92 100644 --- a/gcc/recog.cc +++ b/gcc/recog.cc @@ -3234,7 +3234,8 @@ constrain_operands (int strict, alternative_mask alternatives) else if (constraint_satisfied_p (op, cn)) win = 1; - else if (insn_extra_memory_constraint (cn) + else if ((insn_extra_memory_constraint (cn) + || insn_extra_relaxed_memory_constraint (cn)) /* Every memory operand can be reloaded to fit. */ && ((strict < 0 && MEM_P (op)) /* Before reload, accept what reload can turn