https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102997
--- Comment #25 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to rguent...@suse.de from comment #24) > On Mon, 8 Nov 2021, hubicka at kam dot mff.cuni.cz wrote: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102997 > > > > --- Comment #23 from hubicka at kam dot mff.cuni.cz --- > > > We verify that by simply looking at the loop depth relation of > > > the entry and exit of the path. > > > > Which seem wrong for the path leaving loop and entering another... > > True I guess. The path should end it the same loop as it starts > or end in a loop containing the start loop. Would have to double > check this. Yep, done: // The path should either start and end in the same loop or exit the // loop it starts in but never enter a loop. This also catches // creating irreducible loops, not only rotation. if (entry->src->loop_father != exit->dest->loop_father && !flow_loop_nested_p (exit->src->loop_father, entry->dest->loop_father)) { cancel_thread (&path, "Path rotates loop"); return true; }