From patchwork Thu Nov 25 12:36:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 48130 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E8953858004 for ; Thu, 25 Nov 2021 12:37:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E8953858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637843866; bh=DlPUuMsrZZudiMFdfQdZZALmjqfn2mQOhn1YMWKVLis=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZafC2yG8AKXA+Gc9IfuLcaXEALnPwzopLggOrQwwnhn3M+WnRtRtNg61m8jHxXDjd P2A7EAKryZwqqRnt3mS7Yl+YjMGFHNjbm7lDtwE3YZ29sAeXfXBDc8KOGYwUWXReBt 7bKfocSkIITyFQPPrQ83+s1noDQQMDaphQuqPBP0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id A65223858004 for ; Thu, 25 Nov 2021 12:36:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A65223858004 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DA13A21B37 for ; Thu, 25 Nov 2021 12:36:28 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C693313B81 for ; Thu, 25 Nov 2021 12:36:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kQpVL0yDn2E0EQAAMHmgww (envelope-from ) for ; Thu, 25 Nov 2021 12:36:28 +0000 Date: Thu, 25 Nov 2021 13:36:28 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove never looping loop in label_rtx_for_bb Message-ID: <4785s93-275n-84p-2r48-431n7pq21p68@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This refactors the IL "walk" in a way to avoid the loop which will never iterate. Bootstrapped and tested on x86_64-unknown-linux-gnu, will push later unless there are comments explaining the function is wrong in other ways. Richard. 2021-11-25 Richard Biener * cfgexpand.c (label_rtx_for_bb): Remove dead loop construct. --- gcc/cfgexpand.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index eb6466f4be6..fb84d469f1e 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2461,9 +2461,6 @@ static hash_map *lab_rtx_for_bb; static rtx_code_label * label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED) { - gimple_stmt_iterator gsi; - tree lab; - if (bb->flags & BB_RTL) return block_label (bb); @@ -2472,21 +2469,12 @@ label_rtx_for_bb (basic_block bb ATTRIBUTE_UNUSED) return *elt; /* Find the tree label if it is present. */ - - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - { - glabel *lab_stmt; - - lab_stmt = dyn_cast (gsi_stmt (gsi)); - if (!lab_stmt) - break; - - lab = gimple_label_label (lab_stmt); - if (DECL_NONLOCAL (lab)) - break; - - return jump_target_rtx (lab); - } + gimple_stmt_iterator gsi = gsi_start_bb (bb); + glabel *lab_stmt; + if (!gsi_end_p (gsi) + && (lab_stmt = dyn_cast (gsi_stmt (gsi))) + && !DECL_NONLOCAL (gimple_label_label (lab_stmt))) + return jump_target_rtx (gimple_label_label (lab_stmt)); rtx_code_label *l = gen_label_rtx (); lab_rtx_for_bb->put (bb, l);