From patchwork Wed Jan 13 00:58:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1425572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DFpxN2xbFz9sjB for ; Wed, 13 Jan 2021 11:59:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30AA43938C1C; Wed, 13 Jan 2021 00:59:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 50FE7386101C for ; Wed, 13 Jan 2021 00:59:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 50FE7386101C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Julian_Brown@mentor.com IronPort-SDR: 2KnlgPOP9i6nOCEdvqTB+YY+flqXiIgtf/vJgUFg3umIounPeilqm0iTRbf1CSzn9FzqBTlnY2 x5yml5nU76/u04KPpd3PAc4CkhI9hY4oqVGAEUiLr/52DDafj5L1Jurdt1VwQ2D2MG/BbmxzWa 75UaiGJamzxT3+uKwe9qfnEwE9yWdcI7XpU6LaUR1cZbnEqB3wJEDHTkTC9wPYCPAo9tmbDLur SzHTc7c8FGFpuDw2nFN9I0h8q6fCFhCEK7+KIApkJXAkRUvTlDOyq8wzC+aCkBONtK0uZtPN6M j/g= X-IronPort-AV: E=Sophos;i="5.79,343,1602576000"; d="scan'208";a="57145450" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 12 Jan 2021 16:59:09 -0800 IronPort-SDR: ifGs4b7T2wrksNr6CU/uvDDcbDcuKUsoRj45vtujJ8KS1QrtnhrJT6VEzyVhXmbbNECvZRdHIb /8FcnL0aVSI5BYE0Gk1m4XkbdafAcA81/HNvlVNGwCOCbf72qO/ASKPggJ+ONcy3hpaecQaHdz CNnMdCRCTQmiNg2539VHT8/p3aDIiCADIysXkJHdIsKnfZ3iUmm0PpwfuFoi7tJ6jPxNdJYr75 U/conkD4seoeo5qjGkHh0eK07a+StfraN7MQAwSHHHRaTGL2L5ukxZhzds2tSOGzik8oN+NDFy +Qc= From: Julian Brown To: Subject: [PATCH] amdgcn: Fix exec register live-on-entry to BB in md-reorg Date: Tue, 12 Jan 2021 16:58:51 -0800 Message-ID: <20210113005852.114459-3-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, MEDICAL_SUBJECT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Andrew Stubbs Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This patch fixes a corner case in the AMD GCN md-reorg pass when the EXEC register is live on entry to a BB, and could be clobbered by code inserted by the pass before a use in (e.g.) a different BB. I don't have a standalone test case demonstrating this failure mode, but I did observe it with an offload compiler (on another branch) with a particular benchmark. Tested with standalone AMD GCN target. I will commit shortly. Julian 2021-01-13 Julian Brown gcc/ * config/gcn/gcn.c (gcn_md_reorg): Fix case where EXEC reg is live on entry to a BB. --- gcc/config/gcn/gcn.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index 0fb9bd26727..630ce4eebc7 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -4501,6 +4501,8 @@ gcn_md_reorg (void) df_insn_rescan_all (); } + df_live_add_problem (); + df_live_set_all_dirty (); df_analyze (); /* This pass ensures that the EXEC register is set correctly, according @@ -4522,6 +4524,17 @@ gcn_md_reorg (void) int64_t curr_exec = 0; /* 0 here means 'the value is that of EXEC after last_exec_def is executed'. */ + bitmap live_in = DF_LR_IN (bb); + bool exec_live_on_entry = false; + if (bitmap_bit_p (live_in, EXEC_LO_REG) + || bitmap_bit_p (live_in, EXEC_HI_REG)) + { + if (dump_file) + fprintf (dump_file, "EXEC reg is live on entry to block %d\n", + (int) bb->index); + exec_live_on_entry = true; + } + FOR_BB_INSNS_SAFE (bb, insn, curr) { if (!NONDEBUG_INSN_P (insn)) @@ -4660,6 +4673,8 @@ gcn_md_reorg (void) exec_lo_def_p == exec_hi_def_p ? "full" : "partial", INSN_UID (insn)); } + + exec_live_on_entry = false; } COPY_REG_SET (&live, DF_LR_OUT (bb)); @@ -4669,7 +4684,7 @@ gcn_md_reorg (void) at the end of the block. */ if ((REGNO_REG_SET_P (&live, EXEC_LO_REG) || REGNO_REG_SET_P (&live, EXEC_HI_REG)) - && (!curr_exec_known || !curr_exec_explicit)) + && (!curr_exec_known || !curr_exec_explicit || exec_live_on_entry)) { rtx_insn *end_insn = BB_END (bb);