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: 1854285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SF7G44q2nz23jl for ; Tue, 24 Oct 2023 21:14:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A97D3858D37 for ; Tue, 24 Oct 2023 10:14:34 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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.) */