https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127085

--- Comment #4 from aldy at quesejoda dot com ---
On Thu, Aug 27, 2026 at 08:45:34AM +0000, rguenth at gcc dot gnu.org wrote:
84;0;0c> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127085
> 
> --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
> The issue is that you made a former irreducible region reducible, so a new 
> loop
> appears.  I wonder why you ever want to duplicate the cond over a backedge?
> 
> One way out would be to loops_state_set (LOOPS_NEED_FIXUP) which allows
> new loop discovery.
> 
> In preserves_loop_structure_p you say "requires EDGE_DFS_BACK to be current",
> but the pass doesn't mark backedges.  Instead of checking EDGE_DFS_BACK
> simply never duplicate loop headers.  There's also duplicating blocks
> with exits which requires re-scanning loop exits (but phiopt doesn't have
> recorded exits).
> 
> So I'd change preserves_loop_structure_p to just reject
> 
>   /* Never duplicate loop headers.  */
>   if (e->dest->loop_father->header == e->dest)
>     return false;
> 
> and do loops_state_set (LOOPS_NEED_FIXUP).  If you want to avoid altering
> irreducible regions you'd have to avoid duplicating all blocks with
> incoming backedges, thus mark_dfs_back_edges ().

Thanks so much.  I'll post a patch.

Reply via email to