In comment #3 it's noted that ifcombine happily hoists possibly trapping stmts ... oops.
Fixed like the following, bootstrap and regtest running on x86_64-unknown-linux-gnu. Richard. 2014-06-02 Richard Biener <rguent...@suse.de> PR tree-optimization/61383 * tree-ssa-ifcombine.c (bb_no_side_effects_p): Make sure stmts can't trap. * gcc.dg/torture/pr61383-1.c: New testcase. Index: gcc/tree-ssa-ifcombine.c =================================================================== *** gcc/tree-ssa-ifcombine.c (revision 211125) --- gcc/tree-ssa-ifcombine.c (working copy) *************** bb_no_side_effects_p (basic_block bb) *** 128,133 **** --- 128,134 ---- gimple stmt = gsi_stmt (gsi); if (gimple_has_side_effects (stmt) + || gimple_could_trap_p (stmt) || gimple_vuse (stmt)) return false; } Index: gcc/testsuite/gcc.dg/torture/pr61383-1.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr61383-1.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr61383-1.c (working copy) *************** *** 0 **** --- 1,35 ---- + /* { dg-do run } */ + + int a, b = 1, c, d, e, f, g; + + int + fn1 () + { + int h; + for (;;) + { + g = b; + g = g ? 0 : 1 % g; + e = a + 1; + for (; d < 1; d = e) + { + if (f == 0) + h = 0; + else + h = 1 % f; + if (f < 1) + c = 0; + else if (h) + break; + } + if (b) + return 0; + } + } + + int + main () + { + fn1 (); + return 0; + }