From patchwork Sun Nov 5 18:48:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 161760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2260891vqu; Sun, 5 Nov 2023 10:48:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY2qH8z2nc4gKQ+HQHaqLlrndgfRzQtCd33Vf8XT+QRF/Csf+693uOHgWoHh+DeiCfbmtI X-Received: by 2002:a05:6214:5085:b0:671:d72e:e158 with SMTP id kk5-20020a056214508500b00671d72ee158mr23400257qvb.37.1699210112410; Sun, 05 Nov 2023 10:48:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699210112; cv=pass; d=google.com; s=arc-20160816; b=e/tc2uyWPGPX0TF1r2N1OOXLsltpd/IVOvteAOmwQ2gbzIWcg/XIurQhbRS99ZDnQR jtUGoqsvaWwK6LR/W3/1mrBgrjMubWOgXi8vmrhRuuglNYGjf4ODnrTQucJeR3bcrRI5 mZDgkKIfXSUNnRVXvc+41gWPtIgqyxHVGUPP5ADLL7L+FKHj9smhaPGRqz9yPS4Y6F4n n0Bay0itJu8UED5Tk4bX8gLJNd27G4GcVGOW+nc8kHDHJsFF3ROAihDD8LC0dmh3V1we AkxfzZ48pnEOsSrrASX4tjezIAiZfc+QTNJEFbPGLoK7qPUoVHA95mXDLgKvvV7o+eVE gL5g== 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:in-reply-to:date:references:subject:cc:mail-followup-to :to:from:arc-filter:dmarc-filter:delivered-to; bh=P5BpdDCUFrowDvATD9mPaGhSEm6mL5PQU1XqkOvBsis=; fh=+zKahnQ9dI9rCMQA/vTUSn1PPyLwgfSULGOjxoIZkos=; b=zatS68iUCrN98QwsDO8C6MX71lUSl1DSyejN9r8NFkOnyKL99jR0irGtRhMI/0zVdf HEspSjjvJAdAnut1R2h+asJmcY6elChVjywePalD6f50jzgdf4ou1nUcRWDgyClHXI45 tOafvA8rqSTY2vTLiZWaZA9kH5D2xzluPM1S6u15Beq/IowOCr62CyS96yFBuxfxaTF4 wZd+t/BrsYLlN3d6hYjKJMy7CHHcxkVTQiKqg4zv5XJxvifYwVOyheeAdL/NVKBFVaKr 42vBvr8JxBkP+TjHi/xHEEzhJudtiBkA83Oka/aXXl3MokN9qQlG6443yB2CPHkUJ0Tx /Knw== 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 bj10-20020a05620a190a00b0077a09f1b640si4744685qkb.376.2023.11.05.10.48.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 10:48:32 -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; 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 331F9385AE4E for ; Sun, 5 Nov 2023 18:48:32 +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 BB3893858414 for ; Sun, 5 Nov 2023 18:48:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB3893858414 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 BB3893858414 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=1699210091; cv=none; b=xfA8eEgysSUC7rMC17MoDJ2SMOJdOov7uGmIojSnRHc1b2egy7JkL4zl22GuLDYaRN2txKOqppLq1PDfdjohDLFeCiwX066RNnNnMqTJ83Q2zgABlBObRDAZ6dQ/d1Bz5ZKEFw0SREpqenHUO8ib7SCpHbI1A4eYU395fMvVgU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699210091; c=relaxed/simple; bh=pou0NrWb8QzfPihc+LRuguNOaybSsqUpCQs564xmjSY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=xUDl+y3T0DCacU2t2GdZyTsb3ahLhq9LVDxeNpERa5/q2A6juI0CorYHyHwaZxbMaJkmchk4ABiK2ugkcQnVkH5NekrrwRV1Kvyl5inPfMgkiI6x+axEcl2I560SJApFm4lXMaw0FAMeWHBDehOfHbf8XH7nBpXh8yf0+3Ys6k4= 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 544D2C15; Sun, 5 Nov 2023 10:48:53 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 109563F703; Sun, 5 Nov 2023 10:48:08 -0800 (PST) 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 06/12] mode-switching: Tweak entry/exit handling References: Date: Sun, 05 Nov 2023 18:48:07 +0000 In-Reply-To: (Richard Sandiford's message of "Sun, 05 Nov 2023 18:45:29 +0000") 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.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: 1781750942407696950 X-GMAIL-MSGID: 1781750942407696950 An entity isn't transparent in a block that requires a specific mode. optimize_mode_switching took that into account for normal insns, but didn't for the exit block. Later patches misbehaved because of this. In contrast, an entity was correctly marked as non-transparent in the entry block, but the reasoning seemed a bit convoluted. It also referred to a function that no longer exists. Since KILL = ~TRANSP, the entity is by definition not transparent in a block that defines the entity, so I think we can make it so without comment. Finally, the exit handling was nested in the entry handling, but that doesn't seem necessary. A target could say that an entity is undefined on entry but must be defined on return, on a "be liberal in what you accept, be conservative in what you do" principle. gcc/ * mode-switching.cc (optimize_mode_switching): Mark the exit block as nontransparent if it requires a specific mode. Handle the entry and exit mode as sibling rather than nested concepts. Remove outdated comment. --- gcc/mode-switching.cc | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc index 03dd4c1ebe4..1145350ca26 100644 --- a/gcc/mode-switching.cc +++ b/gcc/mode-switching.cc @@ -650,34 +650,30 @@ optimize_mode_switching (void) } if (targetm.mode_switching.entry && targetm.mode_switching.exit) { - int mode = targetm.mode_switching.entry (e); - info[post_entry->index].mode_out = info[post_entry->index].mode_in = no_mode; - if (pre_exit) - { - info[pre_exit->index].mode_out = - info[pre_exit->index].mode_in = no_mode; - } + int mode = targetm.mode_switching.entry (e); if (mode != no_mode) { - bb = post_entry; - - /* By always making this nontransparent, we save - an extra check in make_preds_opaque. We also - need this to avoid confusing pre_edge_lcm when - antic is cleared but transp and comp are set. */ - bitmap_clear_bit (transp_all, bb->index); - /* Insert a fake computing definition of MODE into entry blocks which compute no mode. This represents the mode on entry. */ - info[bb->index].computing = mode; + info[post_entry->index].computing = mode; + bitmap_clear_bit (transp_all, post_entry->index); + } - if (pre_exit) - info[pre_exit->index].seginfo->mode = - targetm.mode_switching.exit (e); + if (pre_exit) + { + info[pre_exit->index].mode_out = + info[pre_exit->index].mode_in = no_mode; + + int mode = targetm.mode_switching.exit (e); + if (mode != no_mode) + { + info[pre_exit->index].seginfo->mode = mode; + bitmap_clear_bit (transp_all, pre_exit->index); + } } }