Hi, in this testcase peeling of loop contaiing irreducible region leads to increasing size of the region (by removing the conditional path into it). remove_path is not quite ready for this scenario. Still it would be nice to avoid us creating irreducible region in cases where they are not.
Bootstrapped/regtested x86_64-linux, OK? int a, b, c, d, e, f, bar (void); void foo (int x) { for (;;) { if (!x) { for (d = 6; d >= 0; d--) { while (!b) ; if (e) return foo (x); if (f) { a = 0; continue; } for (; c; c--) ; } } if (bar ()) break; e = 0; if (x) for (;;) ; } } PR rtl-optimization/51069 * cfgloopmanip.c (remove_path): Removing path making irreducible region unconditional makes BB part of the region. Index: cfgloopmanip.c =================================================================== *** cfgloopmanip.c (revision 182708) --- cfgloopmanip.c (working copy) *************** remove_path (edge e) *** 290,295 **** --- 290,296 ---- int i, nrem, n_bord_bbs; sbitmap seen; bool irred_invalidated = false; + edge_iterator ei; if (!can_remove_branch_p (e)) return false; *************** remove_path (edge e) *** 329,337 **** /* Find "border" hexes -- i.e. those with predecessor in removed path. */ for (i = 0; i < nrem; i++) SET_BIT (seen, rem_bbs[i]->index); for (i = 0; i < nrem; i++) { - edge_iterator ei; bb = rem_bbs[i]; FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs) if (ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index)) --- 330,341 ---- /* Find "border" hexes -- i.e. those with predecessor in removed path. */ for (i = 0; i < nrem; i++) SET_BIT (seen, rem_bbs[i]->index); + FOR_EACH_EDGE (ae, ei, e->src->succs) + if (ae != e && ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index) + && ae->flags & EDGE_IRREDUCIBLE_LOOP) + irred_invalidated = true; for (i = 0; i < nrem; i++) { bb = rem_bbs[i]; FOR_EACH_EDGE (ae, ei, rem_bbs[i]->succs) if (ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index))