From patchwork Tue Oct 24 10:14:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 157364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1838046vqx; Tue, 24 Oct 2023 03:14:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEunkzT+ab2XX5d2QHQCS00bWXbRqC6DOOmeND4yzz4vAKwj5vTuihunufaUDd8YdDTv5UL X-Received: by 2002:a05:620a:2947:b0:775:7970:5e29 with SMTP id n7-20020a05620a294700b0077579705e29mr14249111qkp.40.1698142486386; Tue, 24 Oct 2023 03:14:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698142486; cv=pass; d=google.com; s=arc-20160816; b=NjmIXbW9nYAcJcHtHwCxySZEpYuX5w0sdeB+6jq2EGYSHPscs+DxRjiY6u4PW8iYsS 1gH/QHRHJn0zeVxj/rn+09Ij/PPDFhszz9sTA+9IljfU7h4POlsTMi9jWXM5IaNege9u m8nqyD3DR/RZH+R+zqp3evO/Eha8fIE4cx+UODrE6ArQkCcc0znQRfBAoffY2RZDlbXd fsOyztd0vDQAGmetDu2fqL6xUPR1U4pbEtwug6FIEknHzZpnnQmjF/UcJie5UOQSxrGA +Z+DaLi6FQPG+U+J+udIjXU0lfcdbsuPd2qFnUr5R4TTv9XAkits+n6rvmelDjB4k7Fn oFoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:subject:cc:mail-followup-to:to:from:arc-filter :dmarc-filter:delivered-to; bh=eeVIl5YJrslQ2dc5tiw0k2IEq+qcnQ9bw0vAFmrMvNI=; fh=+zKahnQ9dI9rCMQA/vTUSn1PPyLwgfSULGOjxoIZkos=; b=fMYrU1mSzzhHAA5NJkvcP9GChk2jKXf+1brcr0myAcMLYeuiTpgk+EnSEddBIRaRA8 R5xoV3p8YYBO4z9FFETnj8A8K0/VbeoU43USpBT8lnqH/OKYY8wZUlvZzs/Jc+JqT4NC 7YxGE45qyRyNNf3UO3C4rZxMY/J4qYy9MYM7czguPnv2pL12MXhWMFSGdYkY6sHzn2ty 8/cbl4BwzqfbFQEcCQBjIH4vMHUUl7Q8ZdE+U5sxWCagHwW0zsmrqDfhqPitvVShqJZL XjdfzG9EeM+LmB5EAkv9Yu96bqO0SHlpoukyiVXyin/n16FSBJP6XCaYb7SP2ds4Fi5z D2Ug== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l4-20020a05620a28c400b0076801d54d1csi5902625qkp.642.2023.10.24.03.14.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:14:46 -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; arc=pass (i=1); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 292183858C01 for ; Tue, 24 Oct 2023 10:14:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 9531B3858D37 for ; Tue, 24 Oct 2023 10:14:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9531B3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9531B3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698142464; cv=none; b=FP9QMg2zm86bcugZX1wrJ0HhGnvj/z3Jn/dNP8eF3Oad53QgDBGAKui5WHu/jjBpvNjIKnk/2ninkgwYMJ0JnPVnWhTBM4hE+YKRJMNa9clUWbSK4gkh31lW/nNL60B3Mr+NGKNB/kDeaHzLr3RZj63wb359CfCfUF/HGhzNy3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698142464; c=relaxed/simple; bh=KkotBT2DyXNRkFr4LtWZIQwtXVDB7o4vCzkhs4k0Jg8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=JLZLE9j2wOYkGRKJSc6/lU6fn/Mr8ORqWCvyt1Yi9wOky/XEZjRGie8CGKVp+di74H5LVLWoXrKctJn/o2P5Gz0dRyfHYlBN3YGFVkKy92e+mgxPWkCsv2sBdckbxHkYELgz6IQmWk0Gh3H2v2NOItykVTjTsfg5yqgILyFIm0U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 40FD32F4; Tue, 24 Oct 2023 03:15:03 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C60083F64C; Tue, 24 Oct 2023 03:14:21 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, jlaw@ventanamicro.com, richard.sandiford@arm.com Cc: jlaw@ventanamicro.com Subject: [PATCH] recog/reload: Remove old UNARY_P operand support Date: Tue, 24 Oct 2023 11:14:20 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-23.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780631455506450896 X-GMAIL-MSGID: 1780631455506450896 reload and constrain_operands had some old code to look through unary operators. E.g. an operand could be (sign_extend (reg X)), and the constraints would match the reg rather than the sign_extend. This was previously used by the MIPS port. But relying on it was a recurring source of problems, so Eric and I removed it in the MIPS rewrite from ~20 years back. I don't know of any other port that used it. Also, the constraints processing in LRA and IRA do not have direct support for these embedded operators, so I think it was only ever a reload-specific feature (and probably only a global/local+reload-specific feature, rather than IRA+reload). Keeping the checks caused problems for special memory constraints, leading to: /* A unary operator may be accepted by the predicate, but it is irrelevant for matching constraints. */ /* For special_memory_operand, there could be a memory operand inside, and it would cause a mismatch for constraint_satisfied_p. */ if (UNARY_P (op) && op == extract_mem_from_operand (op)) op = XEXP (op, 0); But inline asms are another source of problems. Asms don't have predicates, and so we can't use recog to decide whether a given change to an asm gives a valid match. We instead rely on constrain_operands as something of a recog stand-in. For an example like: void foo (int *ptr) { asm volatile ("%0" :: "r" (-*ptr)); } any attempt to propagate the negation into the asm would be allowed, because it's the negated register that would be checked against the "r" constraint. This would later lead to: error: invalid 'asm': invalid operand The same thing happened in gcc.target/aarch64/vneg_s.c with the upcoming late-combine pass. Rather than add more workarounds, it seemed better just to delete this code. Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? Richard gcc/ * recog.cc (constrain_operands): Remove UNARY_P handling. * reload.cc (find_reloads): Likewise. --- gcc/recog.cc | 15 --------------- gcc/reload.cc | 6 ------ 2 files changed, 21 deletions(-) diff --git a/gcc/recog.cc b/gcc/recog.cc index 92f151248a6..e12b4c9500e 100644 --- a/gcc/recog.cc +++ b/gcc/recog.cc @@ -3080,13 +3080,6 @@ constrain_operands (int strict, alternative_mask alternatives) earlyclobber[opno] = 0; - /* A unary operator may be accepted by the predicate, but it - is irrelevant for matching constraints. */ - /* For special_memory_operand, there could be a memory operand inside, - and it would cause a mismatch for constraint_satisfied_p. */ - if (UNARY_P (op) && op == extract_mem_from_operand (op)) - op = XEXP (op, 0); - if (GET_CODE (op) == SUBREG) { if (REG_P (SUBREG_REG (op)) @@ -3152,14 +3145,6 @@ constrain_operands (int strict, alternative_mask alternatives) { rtx op1 = recog_data.operand[match]; rtx op2 = recog_data.operand[opno]; - - /* A unary operator may be accepted by the predicate, - but it is irrelevant for matching constraints. */ - if (UNARY_P (op1)) - op1 = XEXP (op1, 0); - if (UNARY_P (op2)) - op2 = XEXP (op2, 0); - val = operands_match_p (op1, op2); } diff --git a/gcc/reload.cc b/gcc/reload.cc index 2e57ebb3cac..07256b6cf2f 100644 --- a/gcc/reload.cc +++ b/gcc/reload.cc @@ -3077,12 +3077,6 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, enum constraint_num cn; enum reg_class cl; - /* If the predicate accepts a unary operator, it means that - we need to reload the operand, but do not do this for - match_operator and friends. */ - if (UNARY_P (operand) && *p != 0) - operand = XEXP (operand, 0); - /* If the operand is a SUBREG, extract the REG or MEM (or maybe even a constant) within. (Constants can occur as a result of reg_equiv_constant.) */