https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70986
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- The following fixes it for me, making sure the loop is rejected early by if-conversion. Index: gcc/cfganal.c =================================================================== --- gcc/cfganal.c (revision 236066) +++ gcc/cfganal.c (working copy) @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. #include "cfghooks.h" #include "timevar.h" #include "cfganal.h" +#include "cfgloop.h" /* Store the data structures necessary for depth-first search. */ struct depth_first_search_ds { @@ -602,7 +603,10 @@ connect_infinite_loops_to_exit (void) break; deadend_block = dfs_find_deadend (unvisited_block); - make_edge (deadend_block, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE); + edge e = make_edge (deadend_block, EXIT_BLOCK_PTR_FOR_FN (cfun), + EDGE_FAKE); + if (current_loops != NULL) + rescan_loop_exit (e, true, false); flow_dfs_compute_reverse_add_bb (&dfs_ds, deadend_block); }