https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81455
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Ok, so we end up running in circles in find_loop_guard gcond *cond; do { if (single_succ_p (header)) header = single_succ (header); else { cond = dyn_cast <gcond *> (last_stmt (header)); if (! cond) return NULL; extract_true_false_edges_from_block (header, &te, &fe); /* Make sure to skip earlier hoisted guards that are left in place as if (true). */ if (gimple_cond_true_p (cond)) header = te->dest; else if (gimple_cond_false_p (cond)) header = fe->dest; else break; } } while (1); for <bb 4> [85.00%] [count: INV] [loop 3 header]: if (1 != 0) goto <bb 9>; [85.00%] [count: INV] else goto <bb 11>; [15.00%] [count: INV] <bb 11> [12.75%] [count: INV]: goto <bb 5>; [100.00%] [count: INV] <bb 9> [72.25%] [count: INV] [loop 3 latch]: goto <bb 4>; [100.00%] [count: INV] where we walk a latch. We never should do that.