public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5518] Remove never looping loop in label_rtx_for_bb
Date: Thu, 25 Nov 2021 13:24:26 +0000 (GMT)	[thread overview]
Message-ID: <20211125132426.059D13858403@sourceware.org> (raw)

https://gcc.gnu.org/g:0fdd1804ee8ce04821110bb19c246f9d05248e22

commit r12-5518-g0fdd1804ee8ce04821110bb19c246f9d05248e22
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Nov 24 15:57:03 2021 +0100

    Remove never looping loop in label_rtx_for_bb
    
    This refactors the IL "walk" in a way to avoid the loop which will
    never iterate.
    
    2021-11-25  Richard Biener  <rguenther@suse.de>
    
            * cfgexpand.c (label_rtx_for_bb): Remove dead loop construct.

Diff:
---
 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<basic_block, rtx_code_label *> *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 <glabel *> (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 <glabel *> (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);


                 reply	other threads:[~2021-11-25 13:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211125132426.059D13858403@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).