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-1447] Handle multiple latches in irreducible region mark
Date: Tue, 15 Jun 2021 09:18:31 +0000 (GMT)	[thread overview]
Message-ID: <20210615091831.35967398A403@sourceware.org> (raw)

https://gcc.gnu.org/g:dfef1164b1c8d0b7abdf302f94d4be99a75ca791

commit r12-1447-gdfef1164b1c8d0b7abdf302f94d4be99a75ca791
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jun 14 15:36:57 2021 +0200

    Handle multiple latches in irreducible region mark
    
    The following makes irreducible region discovery handle multiple latches.
    
    2021-06-14  Richard Biener  <rguenther@suse.de>
    
            * cfgloopanal.c (mark_irreducible_loops): Use a dominance
            check to identify loop latches.
            * cfgloop.c (verify_loop_structure): Likewise.
            * loop-init.c (apply_loop_flags): Allow marked irreducible
            regions even with multiple latches.
            * predict.c (rebuild_frequencies): Simplify.

Diff:
---
 gcc/cfgloop.c     | 14 ++++++++++----
 gcc/cfgloopanal.c |  2 +-
 gcc/loop-init.c   |  3 ++-
 gcc/predict.c     |  3 +--
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 4e227cd0891..f094538b9ff 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -1555,11 +1555,17 @@ verify_loop_structure (void)
 	  error ("loop %d%'s header does not belong directly to it", i);
 	  err = 1;
 	}
-      if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
-	  && (loop_latch_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP))
+      if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
 	{
-	  error ("loop %d%'s latch is marked as part of irreducible region", i);
-	  err = 1;
+	  edge_iterator ei;
+	  FOR_EACH_EDGE (e, ei, loop->header->preds)
+	    if (dominated_by_p (CDI_DOMINATORS, e->src, loop->header)
+		&& e->flags & EDGE_IRREDUCIBLE_LOOP)
+	      {
+		error ("loop %d%'s latch is marked as part of irreducible"
+		       " region", i);
+		err = 1;
+	      }
 	}
     }
 
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index d0eade3dd34..54426b54881 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -113,7 +113,7 @@ mark_irreducible_loops (void)
 
 	/* Ignore latch edges.  */
 	if (e->dest->loop_father->header == e->dest
-	    && e->dest->loop_father->latch == act)
+	    && dominated_by_p (CDI_DOMINATORS, act, e->dest))
 	  continue;
 
 	/* Edges inside a single loop should be left where they are.  Edges
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 17f14075f62..1fde0ede441 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -48,7 +48,8 @@ apply_loop_flags (unsigned flags)
 	 not work).  However, we avoid modifying cfg, which some
 	 passes may want.  */
       gcc_assert ((flags & ~(LOOPS_MAY_HAVE_MULTIPLE_LATCHES
-			     | LOOPS_HAVE_RECORDED_EXITS)) == 0);
+			     | LOOPS_HAVE_RECORDED_EXITS
+			     | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)) == 0);
       loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
     }
   else
diff --git a/gcc/predict.c b/gcc/predict.c
index 5d0cae5c4a4..d751e6cecce 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -4287,8 +4287,7 @@ rebuild_frequencies (void)
 
   if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
     {
-      loop_optimizer_init (0);
-      mark_irreducible_loops ();
+      loop_optimizer_init (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS);
       connect_infinite_loops_to_exit ();
       estimate_bb_frequencies (true);
       remove_fake_exit_edges ();


                 reply	other threads:[~2021-06-15  9:18 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=20210615091831.35967398A403@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).