]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Handle multiple latches in irreducible region mark
authorRichard Biener <rguenther@suse.de>
Mon, 14 Jun 2021 13:36:57 +0000 (15:36 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 15 Jun 2021 08:31:16 +0000 (10:31 +0200)
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.

gcc/cfgloop.c
gcc/cfgloopanal.c
gcc/loop-init.c
gcc/predict.c

index 4e227cd0891eed3da3e3405dcec8e59068d39325..f094538b9ff033c07b8e13f9c368a9d2a7ec322c 100644 (file)
@@ -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;
+             }
        }
     }
 
index d0eade3dd341a25eb695577577523dc437d0c086..54426b54881f4fc658717478326a6998a53efb39 100644 (file)
@@ -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
index 17f14075f62049269aaa2d9835ccfcde047beb06..1fde0ede441246c163abc0d6f3fc73d625e350a8 100644 (file)
@@ -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
index 5d0cae5c4a4ee72a8df31d653ee4263ebb8b1eaf..d751e6cecce15a6e806198d5d79a489912f9e518 100644 (file)
@@ -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 ();