From patchwork Sun Nov 5 18:47:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1859586 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 4SNk4v5Fxqz1yQL for ; Mon, 6 Nov 2023 05:47:59 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C5917385840F for ; Sun, 5 Nov 2023 18:47:57 +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 658F53857B93 for ; Sun, 5 Nov 2023 18:47:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 658F53857B93 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 658F53857B93 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=1699210067; cv=none; b=s0dBHo3gSbwiiVeL5ioHy80X2CPw5bELGQBPktxTjXyo6wQ+xtbtZ0BLLFrYE4ljclMq3aQAfZO7wzOzAqAsLrZSYb1OTeoMquYqSwelnAZTmM/hzPURiIf4J4J0qPo499WhDjw9OAd8J19SEUsRDNSk2bOE3WyK6w7fPNnu7is= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699210067; c=relaxed/simple; bh=9rif97TBJvNxR85aY7HPVK7rn24N56+gKilYmmnSVmI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=cA57dCukvrIrZRJCOGJxvGTyOjaL74PKGcciDsIEnzx1Fok/k48VHZWJcfH9f8EXS4yHzXOS3VZ04OEWL1TOtJ53O+cmmAVBGUczOH/cPmWHEbt46Ynb8vBcP0knTHRBRmJojCE//duXZhL1jprnZFXMXDh/EX/CspdZvEtkSr8= 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 E666DC15; Sun, 5 Nov 2023 10:48:29 -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 A35723F703; Sun, 5 Nov 2023 10:47:45 -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 05/12] mode-switching: Simplify recording of transparency References: Date: Sun, 05 Nov 2023 18:47:44 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org For a given block, an entity is either transparent for all modes or for none. Each update to the transparency set therefore used a loop like: for (i = 0; i < no_mode; i++) clear_mode_bit (transp[bb->index], j, i); This patch instead starts out with a bit-per-block bitmap and updates the main bitmap at the end. This isn't much of a simplification on its own. The main purpose is to simplify later patches. gcc/ * mode-switching.cc (optimize_mode_switching): Initially compute transparency in a bit-per-block bitmap. --- gcc/mode-switching.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gcc/mode-switching.cc b/gcc/mode-switching.cc index 12ddbd6adfa..03dd4c1ebe4 100644 --- a/gcc/mode-switching.cc +++ b/gcc/mode-switching.cc @@ -556,6 +556,8 @@ optimize_mode_switching (void) bitmap_vector_clear (antic, last_basic_block_for_fn (cfun)); bitmap_vector_clear (comp, last_basic_block_for_fn (cfun)); + auto_sbitmap transp_all (last_basic_block_for_fn (cfun)); + for (j = n_entities - 1; j >= 0; j--) { int e = entity_map[j]; @@ -563,6 +565,8 @@ optimize_mode_switching (void) struct bb_info *info = bb_info[j]; rtx_insn *insn; + bitmap_ones (transp_all); + /* Determine what the first use (if any) need for a mode of entity E is. This will be the mode that is anticipatable for this block. Also compute the initial transparency settings. */ @@ -595,8 +599,7 @@ optimize_mode_switching (void) ins_pos = NEXT_INSN (ins_pos); ptr = new_seginfo (no_mode, no_mode, ins_pos, live_now); add_seginfo (&tail_ptr, ptr); - for (i = 0; i < no_mode; i++) - clear_mode_bit (transp[bb->index], j, i); + bitmap_clear_bit (transp_all, bb->index); } } @@ -611,8 +614,7 @@ optimize_mode_switching (void) { ptr = new_seginfo (last_mode, mode, insn, live_now); add_seginfo (&tail_ptr, ptr); - for (i = 0; i < no_mode; i++) - clear_mode_bit (transp[bb->index], j, i); + bitmap_clear_bit (transp_all, bb->index); any_set_required = true; last_mode = mode; } @@ -643,8 +645,7 @@ optimize_mode_switching (void) ptr = new_seginfo (last_mode, no_mode, BB_END (bb), live_now); add_seginfo (&tail_ptr, ptr); if (last_mode != no_mode) - for (i = 0; i < no_mode; i++) - clear_mode_bit (transp[bb->index], j, i); + bitmap_clear_bit (transp_all, bb->index); } } if (targetm.mode_switching.entry && targetm.mode_switching.exit) @@ -667,8 +668,7 @@ optimize_mode_switching (void) 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. */ - for (i = 0; i < no_mode; i++) - clear_mode_bit (transp[bb->index], j, i); + 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 @@ -688,6 +688,9 @@ optimize_mode_switching (void) FOR_EACH_BB_FN (bb, cfun) { + if (!bitmap_bit_p (transp_all, bb->index)) + clear_mode_bit (transp[bb->index], j, m); + if (info[bb->index].seginfo->mode == m) set_mode_bit (antic[bb->index], j, m);