From patchwork Mon Aug 14 02:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 1820821 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=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RPJ19669qz1yfZ for ; Mon, 14 Aug 2023 12:16:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB866385842A for ; Mon, 14 Aug 2023 02:16:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from arjuna.pair.com (arjuna.pair.com [209.68.5.131]) by sourceware.org (Postfix) with ESMTPS id 7A8073858D39 for ; Mon, 14 Aug 2023 02:16:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A8073858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bitrange.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bitrange.com Received: by arjuna.pair.com (Postfix, from userid 3006) id 222BA8A639; Sun, 13 Aug 2023 22:16:17 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by arjuna.pair.com (Postfix) with ESMTP id 1E63B8A56E; Sun, 13 Aug 2023 22:16:17 -0400 (EDT) Date: Sun, 13 Aug 2023 22:16:17 -0400 (EDT) From: Hans-Peter Nilsson X-X-Sender: hp@arjuna.pair.com To: gcc-patches@gcc.gnu.org cc: vmakarov@redhat.com Subject: [committed] MMIX: Handle LRA FP-to-SP-elimination oddity Message-ID: User-Agent: Alpine 2.20.16 (BSF 172 2016-09-29) MIME-Version: 1.0 X-Scanned-By: mailmunge 3.11 on 209.68.5.131 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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.29 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 Sender: "Gcc-patches" When LRA is in progress, it can try and validate insns half-way through frame-pointer (FP) to stack-pointer (SP) elimination. Operands have then been substituted where the offset is from the SP elimination but the register is the (hard) frame-pointer: lra-eliminations.cc:lra_eliminate_regs_1:370: rtx to = subst_p ? ep->to_rtx : ep->from_rtx; In this regard reload played nicely. Unfortunately, the frame_pointer_operand predicate in mmix/predicates.md barfs on such an address. This broke the use of the MMIX frame_pointer_operand predicate (and the Yf constraint), used only in the nonlocal_goto_receiver expansion (which is used in e.g. code generated for C++ "catch"). Force MMIX frame_pointer_operand to accept an FP+offset for the duration of lra_in_progress. * config/mmix/predicates.md (frame_pointer_operand): Handle FP+offset when lra_in_progress. --- gcc/config/mmix/predicates.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/config/mmix/predicates.md b/gcc/config/mmix/predicates.md index 4a9b0177a786..64e77fa92d00 100644 --- a/gcc/config/mmix/predicates.md +++ b/gcc/config/mmix/predicates.md @@ -171,4 +171,14 @@ (define_predicate "frame_pointer_operand" (match_code "plus") (match_code "reg" "0") (match_code "const_int" "1") - (match_test "XEXP (op, 0) == stack_pointer_rtx")))) + (ior + (match_test "XEXP (op, 0) == stack_pointer_rtx") + ;; We can temporarily have a FP+offset here, where we (for FP) + ;; accept only FP and the equivalent elimination of SP+offset. + ;; See lra_eliminate_regs_1 in lra-eliminations.cc c:a line 370: + ;; "rtx to = subst_p ? ep->to_rtx : ep->from_rtx;" + (and + (match_test "lra_in_progress") + (ior + (match_test "XEXP (op, 0) == hard_frame_pointer_rtx") + (match_test "XEXP (op, 0) == frame_pointer_rtx")))))))