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.
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;
+ }
}
}
/* 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
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
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 ();