https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80549
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |law at gcc dot gnu.org --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- As (I believe) CFG cleanup preserves single-entry loops (single entry headers) and a latch cannot become an entry maintaining this CFG property throughout the compilation pipeline might make sense (and might be not too intrusive either). That would be certainly cheaper than doing this again and again (when usually it will not be necessary). So doing instead Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 247362) +++ gcc/tree-cfg.c (working copy) @@ -402,7 +402,7 @@ execute_build_cfg (void) dump_scope_blocks (dump_file, dump_flags); } cleanup_tree_cfg (); - loop_optimizer_init (AVOID_CFG_MODIFICATIONS); + loop_optimizer_init (LOOPS_HAVE_PREHEADERS); replace_loop_annotate (); return 0; } fixes it up to the point where DOM (via threading) introduces another edge to the header. ISTR I tried to "fix" this before, by inserting a preheader at that point. Basically it threads through the preheader to the loop header itself. Avoiding that would be nice -- ending the path one block earlier or creating a forwarder.