https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100492
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah, no - there's an irreducible region inside the inner loop. The logic
/* In distribution of loop nest, if bb is inner loop's exit_bb,
we choose its exit edge/path in order to avoid generating
infinite loop. For all other cases, we choose an arbitrary
path through the empty CFG part that this unnecessary
control stmt controls. */
if (gcond *cond_stmt = dyn_cast <gcond *> (stmt))
{
if (inner_exit && inner_exit->flags & EDGE_TRUE_VALUE)
gimple_cond_make_true (cond_stmt);
else
gimple_cond_make_false (cond_stmt);
update_stmt (stmt);
}
only works for conditions exiting the loop (where we asked for a single-exit
earlier) and for conditions not controlling a cycle (where it doesn't matter
which way we go).
There's no sweep over stmts qualifying a loop body, but
find_seed_stmts_for_distribution could be abused that way. We could also
simply forcefully put this condition in all partitions or we could see
whether to use post-dominance we compute for control dependence can be
used to find the edge towards exit.