From patchwork Tue Apr 18 10:13:55 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: 84734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2730415vqo; Tue, 18 Apr 2023 03:14:58 -0700 (PDT) X-Google-Smtp-Source: AKy350b0Z/R3voTzEKW8yfsP+lx1g9uuhLP0rpuXtpkiXs4WqRCP6CNoOjC7N4B3kWicc11h3AZS X-Received: by 2002:a05:6402:5159:b0:506:84e0:a78a with SMTP id n25-20020a056402515900b0050684e0a78amr1864267edd.3.1681812898026; Tue, 18 Apr 2023 03:14:58 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v20-20020a056402185400b00506985655f0si6003982edy.355.2023.04.18.03.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 03:14:58 -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="vbK/KQ+5"; 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 D3EEC3858D1E for ; Tue, 18 Apr 2023 10:14:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3EEC3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681812896; bh=AThHSURIxIOsqznllwFsVvtsjtbLuWuq8v5OaRU7Z5U=; h=Date:To:CC:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=vbK/KQ+5LIceM8Ig9mgCdcZ8kNurSHsNS+QKd3akUxfeJBwN9hORMXUoyzntGqAbQ EDuLNr0eIduRWUPREmoUtHcCx8T3KyeMAljmGKhNMznri2o5mkooB1FuCTKVVba/GE CKKfEueTm8SU6vYtNKVAv4PrKkpftuEJw60cRgRM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2073.outbound.protection.outlook.com [40.107.7.73]) by sourceware.org (Postfix) with ESMTPS id C3A0B3858D1E for ; Tue, 18 Apr 2023 10:14:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3A0B3858D1E Received: from DU2PR04CA0331.eurprd04.prod.outlook.com (2603:10a6:10:2b4::19) by DB9PR08MB6731.eurprd08.prod.outlook.com (2603:10a6:10:2a4::16) 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 10:14:05 +0000 Received: from DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b4:cafe::bf) by DU2PR04CA0331.outlook.office365.com (2603:10a6:10:2b4::19) 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 10:14:05 +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 DBAEUR03FT040.mail.protection.outlook.com (100.127.142.157) 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 10:14:05 +0000 Received: ("Tessian outbound 5154e9d36775:v136"); Tue, 18 Apr 2023 10:14:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0059856a8471de09 X-CR-MTA-TID: 64aa7808 Received: from c86ed6f0134d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 77CE4C6E-757F-4029-B101-F3782A00B068.1; Tue, 18 Apr 2023 10:13:58 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c86ed6f0134d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 Apr 2023 10:13:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oc2dTRB0K2/cYCBfpbXrU4HRKwtt7eoSo+o0Bln5+Il/OD+2UFauMcJyNzJnw3xI0qwajhEtyXMR8yPiKLYdvRBmv+Xw1qLwyWNEdFOLkDAJSTtSruuGAwu2f7Ur+fkSfKh8CHSsjVXx7vKCiNAjkhHYiWhpO5EzvCF5beRN5UvR/CnhAr1mefFW3nHij6mY0MQdLpO4uDBqDYlK6exbtM71Rv1fW7uLnzBGVs1UFPJbyow1M400VFagluo44dLBhLop7+yLNANhLFthap6qT44Vc/fHjbAXQeZv+7ek+V6l6cT8MEukPfszcoCKKvYyEha0+rtw8F46i1Bk+f2VEw== 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=AThHSURIxIOsqznllwFsVvtsjtbLuWuq8v5OaRU7Z5U=; b=iFV5UKFa5DJNJa1l/wr3yf5qaVSKozrx2wHup8nCiMrvVTFZb5J2rr5+d+CklvHkXR4eUqiz73Wo6g2vMJdCgDvOam9XQCdjBMJSiNqTAocKUrP9p5LnnzcIho9qnlbFRU0VC1NDfTVBccKT6G0ddN23NWFuLeqk/SvhzCWgIlmlw86YoGfMlgkmCfw3rkgmoi/6sGx5kjXcig6Pd9ohTfHRqoF4AgXuFrS7/JbFUCI3wy/zDIueBFeix/300X/edaGNotoEDvNE7Q1fC7GJ+JZdpXWLInLAHeFVK3y/N1M3eOroVF/8yg5ptetLcnrm30/wTqHhKxV8a4A0a8j+5Q== 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 AS9PR06CA0107.eurprd06.prod.outlook.com (2603:10a6:20b:465::31) by DU0PR08MB9274.eurprd08.prod.outlook.com (2603:10a6:10:41a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Tue, 18 Apr 2023 10:13:57 +0000 Received: from AM7EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:465:cafe::b0) by AS9PR06CA0107.outlook.office365.com (2603:10a6:20b:465::31) 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 10:13:57 +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 AM7EUR03FT050.mail.protection.outlook.com (100.127.141.27) 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 10:13:57 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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 10:13:56 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) 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 10:13:55 +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 10:13:55 +0000 Date: Tue, 18 Apr 2023 11:13:55 +0100 Message-ID: To: CC: , Subject: [PATCH] constraint: fix relaxed memory and repeated constraint handling MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT050:EE_|DU0PR08MB9274:EE_|DBAEUR03FT040:EE_|DB9PR08MB6731:EE_ X-MS-Office365-Filtering-Correlation-Id: 62c6401c-468e-4955-f177-08db3ff5a3f0 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: 45oEZ0SyiFoRNXhDOX6LWORuJpycJ5DD43TzcU4GnDxVBxUNZWs7+uxfq7pqASSshiPOP2RgS4Q1tP4ugEG8ZAMIvBRalU/rSWJA5smTkK0dehqlTjNN4o4DIoWWePW8W+Ps5uMn83/I4WQZyh4thKcjr4DHBX4SLT1nsqA2/of3VxL2emA0p7z0W9B8VXn5oAjCS/89/IgydKO5DbQ3JbA7aiXSjCs8YE1AJc7MmC1PJuW8sJY4tDw6GujqD/od8a9cdYia19EaHN7jYShrDJcEJsLrXpmNGP03k35i0GHslXbMQVVzVYO1GNTp8Txdn+/w7I8PlPustT0U21iYa50f6CnrxOvL/3s1KS9aNkuhExs7FiptacCmFEl08Q83jUp5XKQD7ObEMvBh6vVda3VG4/hkQiNejRhg3sIilC8wBHk6RQthIvGFt95ZSfHx+ZFPA+RerOIEyNkb25wmUbwU0UhbLOk74Wl9MrawjST5Vh55OxapRki9j5blEMw4+4LP02RIRs7P6sKFv2ZYHdU/n7gCXizuf3ChLv7z5CDxZTKlUOt8bVmGqx5UwKHVhpH4MpPvhswmwVnfIyXplH8wQykIiPyxIWQ/v+cwvlEKjHyxItaN5ymiOlubeSap3TuaWNl+H/vFrBprs7jNhbuVA4xPkwIdj/eye+HH2T0niKdruIlR9uVHA8Yp7rVN3ag5B+/o6zk9EtRkXxQK0Q== 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)(136003)(396003)(376002)(39860400002)(346002)(451199021)(36840700001)(46966006)(316002)(4326008)(6916009)(82740400003)(70206006)(70586007)(5660300002)(2616005)(336012)(426003)(47076005)(86362001)(82310400005)(36756003)(41300700001)(54906003)(40480700001)(26005)(186003)(66899021)(2906002)(83380400001)(8676002)(8936002)(36860700001)(478600001)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9274 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1abfed00-d00e-4360-c1ad-08db3ff59f0f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2LsPOwmtjE/pz3EoiM8DKqX5gHvZkqLwtuLWSUMFUFsmrg2abSCMCKLBJlKmT4cvLv/V46e+NjaC8uqoIJiAe/l/KbhssY0woV7ZaTqfe3H90ag9+I2fmN/KPyaD42mIMoe/pQD/TLkwzTtU2QNIDTPS65vC4raUtv2F7AKRC9fDOIBF/W4EfzFnbN/cZzGrucDoImWWsDQ9mmXUBNdbColCiOHfOkI8EgFG2XjsJw/ChQSSKzpxpnxaHuW0TlcMxelm2D+enNkeTpIUJWe6Az4CkRqckQiheWBvR3fYvs/NEhM6rlMYAeToroxYVzObyO2cmDuoy9Y/8k8wQqmRXHbliqhX5Q9rpAv1DaqQJsnOGkBEMr8xRcTwTkYjHbh4/sXTSke9C8p8J3byLESStRZvBR8DEi7A2XbDl7NtJkNfLt1jHN6jkVjaN7jrZfZcaJ1FSIUpF+svwMkbuhqpYr2+zeBo8rK2AqKUjksYUBItqJYlLb2ak5zRCUwSOjaHz6LU8+zEj5JOghQtsO1nU1SELAWvNs9SEeAPdcFUt3nfgHnN9Trn80HCoYlhOPjmCobiBPwn0VifaU+SFrEckuaI7uTuM9G1+X0AAHxSw7t1/ddfylEzxfxItKbJ14U3SXC+V+oa69DKJuDZJyzSynpLn8I+sTllbAuoKjTDVmduQ/aNzszDknMkveR554dGlJ+tdQYhhOkREqMTe0z23w== 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)(376002)(136003)(346002)(396003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(336012)(478600001)(86362001)(2616005)(47076005)(36756003)(426003)(36860700001)(40480700001)(26005)(83380400001)(186003)(40460700003)(82740400003)(70586007)(70206006)(81166007)(316002)(2906002)(4326008)(6916009)(8936002)(5660300002)(8676002)(41300700001)(82310400005)(66899021)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2023 10:14:05.3071 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62c6401c-468e-4955-f177-08db3ff5a3f0 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: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6731 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?1763508641517998709?= 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 | 40 +++++++++++++++++++++++++++++++++++++--- gcc/recog.cc | 3 ++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index dd4f68bbfc0..6a13e64d7e1 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -3448,6 +3448,42 @@ skip_constraint_modifiers (const char *str) } } +/* Takes a string of 0 or more comma-separated constraints and the + constraint_num correspondig to the first constraint. When more + than one constraint 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); + } + /* Treat the special case of an uninitialized ca. */ + if (ca == CONSTRAINT__UNKNOWN) + ca = cb; + /* Treat 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 +3543,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