From patchwork Thu Feb 16 14:27:46 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: 58107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp558679dyf; Thu, 16 Feb 2023 06:29:13 -0800 (PST) X-Google-Smtp-Source: AK7set8Zg34nVjIwKlbz3S21AjcKwcvOVrdT2dIfcG0OwM5zsVhf/m6Yaep+R/UrEmhSS2OhgDlc X-Received: by 2002:a17:906:9f25:b0:8b1:2eef:154c with SMTP id fy37-20020a1709069f2500b008b12eef154cmr2167408ejc.0.1676557753331; Thu, 16 Feb 2023 06:29:13 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id fs36-20020a170907602400b008b125aca810si1739207ejc.721.2023.02.16.06.29.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 06:29:13 -0800 (PST) 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=@gcc.gnu.org header.s=default header.b=u3+bVcCA; arc=fail (signature failed); 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"; 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 CEB1B3858412 for ; Thu, 16 Feb 2023 14:29:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEB1B3858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676557751; bh=Vs1E6v8Brl45ODMigIJ4DkwhQP+c+ZguLIV3B0HlaBc=; h=Date:To:CC:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=u3+bVcCAAT3bwd4ICIA9vhTpyaBb0cZTAHACqGLKO/oUFombpoRWlw1yDhYlK+LYg GHBiudvWpOqMy4IiunnBRvQmi3RnG/XtVpTBAGItpHHBQuxN2srX/z1YoI01Rx5rwY wNuhAutIKQX9pPBWxtGbo1KVvz+Gd1CeQO+1L2is= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2079.outbound.protection.outlook.com [40.107.247.79]) by sourceware.org (Postfix) with ESMTPS id 8DD383858D33 for ; Thu, 16 Feb 2023 14:28:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8DD383858D33 Received: from DB6PR0301CA0007.eurprd03.prod.outlook.com (2603:10a6:4:3e::17) by GV2PR08MB9280.eurprd08.prod.outlook.com (2603:10a6:150:e1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 14:28:22 +0000 Received: from DBAEUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3e:cafe::d3) by DB6PR0301CA0007.outlook.office365.com (2603:10a6:4:3e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26 via Frontend Transport; Thu, 16 Feb 2023 14:28:22 +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 DBAEUR03FT049.mail.protection.outlook.com (100.127.142.192) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 14:28:22 +0000 Received: ("Tessian outbound 3ad958cd7492:v132"); Thu, 16 Feb 2023 14:28:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9a4aff3bbf6d023f X-CR-MTA-TID: 64aa7808 Received: from 2ad4a2fa5686.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6B87957D-E099-4C6D-8E91-CB5FBB8A23D4.1; Thu, 16 Feb 2023 14:28:15 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2ad4a2fa5686.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 16 Feb 2023 14:28:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ogK9dVqsRKz1+exNUDRfnHceLM0iYsu0oJrHHyhEQ06ukEawqRKuAIY/h4P/v4OVryukn5ZBf0is67ySrF7Z5zw39lkDvBm7+jrIegbxvZNW+T4UKB6jofdpOnkQcXt7pnNcq/yRX0tatd5cQop6mi4LqZ04EPLq4GV5rEcXf/7OBP7CXHoWVbR4BSJDfK3K8JBz81VlWu8IHgP1xAzYTiL1yW8ggpGWK0eBvzGU3FsENCDACxDWn0lFmA/KKX6Un5zFg3o9EBzu9DDdPlSJfDNQiHvb5NRPeeOe12u+JQ9hGkfviHRwRsmLn/GI4xs7yODm7hAN6avC1MAYeBllmw== 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=Vs1E6v8Brl45ODMigIJ4DkwhQP+c+ZguLIV3B0HlaBc=; b=BzJY6OGD2dz9ti2E0U6JGnjE+GMF1HudZEdBbx6W8/KV4cTpNNaSDLWHZIEKwkCwPM5NJYQ6/RHzAvhSmzdANfhFI2QrhPWq8nXCQRVTHUbjb2+BDs5PCFU4NkNVliYVetbaHMmrhSz8/4T7PQ7rsCjy0CKLtXsN9ZcWwUJwLnhhcpvg4w34ppQRzwbqtLyUGjxTJBsfj+n56IgSI9wVXzy7XSDdwp+egaqQpIZ6ErS3Gul9or9isjYxx5NDSVjTkzIs4euGywyw1/5qtqDxIKkdZcuzWOWO8/xgq3hN8BOcN8RkbwGaydxhaAbKDshf//HIAa4txh9uyiU6RXUXiw== 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 DU2PR04CA0336.eurprd04.prod.outlook.com (2603:10a6:10:2b4::15) by PR3PR08MB5817.eurprd08.prod.outlook.com (2603:10a6:102:82::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.24; Thu, 16 Feb 2023 14:28:12 +0000 Received: from DBAEUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b4:cafe::b7) by DU2PR04CA0336.outlook.office365.com (2603:10a6:10:2b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.12 via Frontend Transport; Thu, 16 Feb 2023 14:28:12 +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 DBAEUR03FT041.mail.protection.outlook.com (100.127.142.233) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6111.13 via Frontend Transport; Thu, 16 Feb 2023 14:28:12 +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.17; Thu, 16 Feb 2023 14:28:09 +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.17; Thu, 16 Feb 2023 14:28:09 +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.17 via Frontend Transport; Thu, 16 Feb 2023 14:28:09 +0000 Date: Thu, 16 Feb 2023 14:27:46 +0000 Message-ID: To: CC: , Subject: [PATCH] constraint: fix relaxed memory and repeated constraint handling MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT041:EE_|PR3PR08MB5817:EE_|DBAEUR03FT049:EE_|GV2PR08MB9280:EE_ X-MS-Office365-Filtering-Correlation-Id: b8806504-7991-4aeb-2841-08db102a0e92 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: 4LxMHvSqgGhXEsbZiqmAywqKCVfWXDdyKD4KvuP+poYK27fDEcCVbfaW2Onz4bi6KGWjge/TnOr41cwUaV6Hh2h4BOSlmHou1/6i1ik860HZbM9w4M7UR3RUi2iAf8n4GdT/+KYEcAyG6e9LJoxfIWUOatRlXTbhOEXL3nXs20B//CzGrkRCOngj4/mQSe76A84nFC4swNhUMwUNpWXCjwInJKL3HQ+JUZjoEjHyXm7yxrve1vP9u7K6nCzQBbOIZm1zHrVpIdJWWmw5FU64tQn/5DamvoEmmo5uHHRH19WsiJWVuuWdLQOyBdDY65/OiJMH6PE6k/0K9NcbrWtSLDSfu0TOkZzXRc89COUf0mxLFG3o3H3DncO0R7LROfrHtBE/UqqmwWI9tUemmpGkf5GF5AHzx654Eu0Gwb9oK64mrKJ4h38dus2fLMucoG1/ypTyPqAUQvOifVZhPooDrRRxF4TfSJ1N8ANupbl1DpSM021AW78jB1cEBP242QBGIM7E9G+e8TAExeHUR0ZIpB80dAlGUSl2JugpE0lsBRNj065uZq2XZljG2VhfIxjyZW0uBuhaWr3LWya0cD7SR1F9qgSfjRnUAChKDlsa+hIwutbt2YLQ3ECSSIOSaVnwSFgWvODnEtfGMsKLodSqyXiTLo3Zo3I3YCW2t5I0V3NZ7hLrxgIc81Nmwv2LebHeDR+OrkqIg5XM5t9IeF4EELcsIhFjn6FPxSnNIG5LKLQ= 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:(13230025)(4636009)(39860400002)(396003)(376002)(136003)(346002)(451199018)(40470700004)(46966006)(36840700001)(66899018)(82310400005)(40460700003)(4326008)(6916009)(54906003)(70586007)(41300700001)(70206006)(356005)(316002)(86362001)(40480700001)(82740400003)(81166007)(36860700001)(36756003)(26005)(186003)(2616005)(6666004)(336012)(8936002)(8676002)(2906002)(478600001)(426003)(47076005)(5660300002)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5817 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 812c5b31-a033-418f-12b5-08db102a08ec X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P95sH5O/qlCY5tAJ0KeKZU/VJzmHkB/QfORqTKAesdf2RV0gg5bvaqt8J6z7vAj6M4isauXgL3vhT8unr9pwtgsG5mSUDgzn+BJZTr17jAkK1MAdsSK2UnqwCkngN28yN+deUjA8ioRQlr7rhSf+uy5VCpTtW5lxzbyPzn/NzUU/qS1+5mUAImzhAuXFEDfUVTQGZg92e4UEwKgoDJNZdVuP5lOf6xIu00e42BTsSefTABDqcS3LToM1Cn/eK11zIAwBn12Gizt7DgKsu+Zbr0+VfpxNqu3xqctBDdmJjOhe2Z3hBE3OEb0RsiAByzSdY5txTFZ72I7YhNqyO/bsYuSDGkP4qx3UdGy/UxAgaortKwpB4W3ipLt4pthLqIlnCR4nKisqYDV68Eol4L9H5ah9jsNQHiHpIlJ5quIw92oeFGuUjlgsx5JBF3rC6dPkF+Ws14RU53t4COC7XPB+bSZ3Eo2gsx/Xf79nxlCtU6Fqofp7gQvZ3B1eXDa0bXD57KHaRkvTho/OU4eEKUgkPVtlpkOL8D3cGl8cAnNSDgTAddMfktY/Du0AS1gjZD+E6BdnTJ2SVqP7YKPFm0qHfFEO7HowkIO9+t3hc7y86Ebym6RIOYS6uYCPevHRafrP0z21XgUAR7Dhz8TZuFRYDaLeaHqH6C9u/8DkeAvtjBWGG8nTf5kLEKr0bFWWnN+vxN8F1N7aqIdjiUBJIZSPrg== 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:(13230025)(4636009)(39860400002)(136003)(346002)(376002)(396003)(451199018)(40470700004)(46966006)(36840700001)(8936002)(86362001)(40460700003)(41300700001)(5660300002)(81166007)(82740400003)(4326008)(70206006)(2906002)(6916009)(82310400005)(66899018)(8676002)(36860700001)(70586007)(40480700001)(316002)(54906003)(336012)(2616005)(478600001)(426003)(83380400001)(47076005)(36756003)(6666004)(186003)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 14:28:22.2031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8806504-7991-4aeb-2841-08db102a0e92 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: DBAEUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9280 X-Spam-Status: No, score=-12.9 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, 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?1757998222392912431?= X-GMAIL-MSGID: =?utf-8?q?1757998222392912431?= 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 | 43 +++++++++++++++++++++++++++++++++++++++--- gcc/recog.cc | 3 ++- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index dbfaf0485..c9c1653c0 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -3448,6 +3448,45 @@ 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) +{ + enum constraint_num cb; + for (;;) + { + /* Skip past current constraint and any whitespace which may + precede the end-of-line or separator characters. */ + cstr = skip_constraint_modifiers (cstr + + CONSTRAINT_LEN (cstr[0], cstr)); + /* If end of string reached and no disagreement found, we have + uniqueness. */ + if (*cstr == '\0') + return true; + /* skip_constraint_modifiers does not handle commas, handle + case manually. */ + if (*cstr == ',') + cstr++; + /* Get next constraint. */ + cstr = skip_constraint_modifiers (cstr); + cb = lookup_constraint ((*cstr == '\0' || *cstr == ',') ? "X" : cstr); + + /* If mismatch found, break out of loop. */ + if (cb != ca) + return false; + + /* If *cstr == '\0', we don't want to reach the + skip_constraint_modifiers statement again as that will + advance the pointer past the end of the string. */ + if (*cstr == '\0') + return true; + } +} + /* 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 +3546,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)) 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 200cf4214..3ddeab59d 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