https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85455
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2018-04-19 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Target Milestone|--- |8.0 Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- So we end up in bool cleanup_cfg (int mode) { ... with mode == 41 and /* ??? We probably do this way too often. */ if (current_loops && (changed || (mode & CLEANUP_CFG_CHANGED))) { timevar_push (TV_REPAIR_LOOPS); /* The above doesn't preserve dominance info if available. */ gcc_assert (!dom_info_available_p (CDI_DOMINATORS)); calculate_dominance_info (CDI_DOMINATORS); fix_loop_structure (NULL); free_dominance_info (CDI_DOMINATORS); timevar_pop (TV_REPAIR_LOOPS); } here changed is false and mode doesn't include CLEANUP_CFG_CHANGED. while (try_optimize_cfg (mode)) { returns false here so changed isn't set but the call wrecks loop info. That is because of if (mode & (CLEANUP_CROSSJUMP | CLEANUP_THREADING)) clear_bb_flags (); and /* Bit mask for all basic block flags that must be preserved. These are the bit masks that are *not* cleared by clear_bb_flags. */ #define BB_FLAGS_TO_PRESERVE \ (BB_DISABLE_SCHEDULE | BB_RTL | BB_NON_LOCAL_GOTO_TARGET \ | BB_HOT_PARTITION | BB_COLD_PARTITION) which doesn't include loop related flags. This is a latent issue, certainly not a regression in general(?), a fix could be Index: gcc/cfg.c =================================================================== --- gcc/cfg.c (revision 259486) +++ gcc/cfg.c (working copy) @@ -386,9 +386,13 @@ void clear_bb_flags (void) { basic_block bb; + int flags_to_preserve = BB_FLAGS_TO_PRESERVE; + if (current_loops + && loops_state_satisfies_p (cfun, LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)) + flags_to_preserve |= BB_IRREDUCIBLE_LOOP; FOR_ALL_BB_FN (bb, cfun) - bb->flags &= BB_FLAGS_TO_PRESERVE; + bb->flags &= flags_to_preserve; } /* Check the consistency of profile information. We can't do that