This fixes PR58326, fix_bb_placements via unloop does not properly mark all blocks with uses that are now eventually subject to loop-closed SSA handling.
Fixed with the following, bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2013-09-09 Richard Biener <rguent...@suse.de> PR middle-end/58326 * cfgloopmanip.c (fix_bb_placements): When fixing the placement of a subloop record all its block as affecting loop-closed SSA form. * gcc.dg/torture/pr58326-1.c: New testcase. * gcc.dg/torture/pr58326-2.c: Likewise. Index: gcc/cfgloopmanip.c =================================================================== *** gcc/cfgloopmanip.c (revision 202382) --- gcc/cfgloopmanip.c (working copy) *************** fix_bb_placements (basic_block from, *** 223,237 **** if (!fix_loop_placement (from->loop_father, irred_invalidated)) continue; target_loop = loop_outer (from->loop_father); } else { /* Ordinary basic block. */ if (!fix_bb_placement (from)) continue; if (loop_closed_ssa_invalidated) bitmap_set_bit (loop_closed_ssa_invalidated, from->index); - target_loop = from->loop_father; } FOR_EACH_EDGE (e, ei, from->succs) --- 223,244 ---- if (!fix_loop_placement (from->loop_father, irred_invalidated)) continue; target_loop = loop_outer (from->loop_father); + if (loop_closed_ssa_invalidated) + { + basic_block *bbs = get_loop_body (from->loop_father); + for (unsigned i = 0; i < from->loop_father->num_nodes; ++i) + bitmap_set_bit (loop_closed_ssa_invalidated, bbs[i]->index); + free (bbs); + } } else { /* Ordinary basic block. */ if (!fix_bb_placement (from)) continue; + target_loop = from->loop_father; if (loop_closed_ssa_invalidated) bitmap_set_bit (loop_closed_ssa_invalidated, from->index); } FOR_EACH_EDGE (e, ei, from->succs) Index: gcc/testsuite/gcc.dg/torture/pr58326-1.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr58326-1.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr58326-1.c (working copy) *************** *** 0 **** --- 1,23 ---- + /* { dg-do compile } */ + + int a, *d; + long b; + short c; + + void foo () + { + int e; + lbl: + for (c = 0; c < 2; c++) + { + if (1 >> b) + break; + e = *d; + for (; a; a++) + { + *d = e; + if (b) + goto lbl; + } + } + } Index: gcc/testsuite/gcc.dg/torture/pr58326-2.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr58326-2.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr58326-2.c (working copy) *************** *** 0 **** --- 1,20 ---- + /* { dg-do compile } */ + + int a, b, c, d; + + void foo () + { + int e; + + lbl: + for (c = 0; c < 2; c++) + { + e = d; + for (; a; a++) + { + d = e; + if (b) + goto lbl; + } + } + }