This fixes PR57214 - the simple constant propagation pass we perform over unrolled loop bodies does not properly avoid propagating across abnormal edges.
Bootstrap & regtest running on x86_64-unknown-linux-gnu, I'll install this on trunk and the 4.8 branch where the bug is latent. Richard. 2013-05-10 Richard Biener <rguent...@suse.de> PR tree-optimization/57214 * tree-ssa-loop-ivcanon.c (propagate_constants_for_unrolling): Do not propagate from SSA names that occur in abnormal PHI nodes. Index: gcc/tree-ssa-loop-ivcanon.c =================================================================== *** gcc/tree-ssa-loop-ivcanon.c (revision 198768) --- gcc/tree-ssa-loop-ivcanon.c (working copy) *************** propagate_constants_for_unrolling (basic *** 1085,1092 **** tree lhs; if (is_gimple_assign (stmt) && (lhs = gimple_assign_lhs (stmt), TREE_CODE (lhs) == SSA_NAME) ! && gimple_assign_rhs_code (stmt) == INTEGER_CST) { propagate_into_all_uses (lhs, gimple_assign_rhs1 (stmt)); gsi_remove (&gsi, true); --- 1085,1093 ---- tree lhs; if (is_gimple_assign (stmt) + && gimple_assign_rhs_code (stmt) == INTEGER_CST && (lhs = gimple_assign_lhs (stmt), TREE_CODE (lhs) == SSA_NAME) ! && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) { propagate_into_all_uses (lhs, gimple_assign_rhs1 (stmt)); gsi_remove (&gsi, true); Index: gcc/testsuite/gcc.dg/torture/pr57214.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr57214.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr57214.c (working copy) *************** *** 0 **** --- 1,25 ---- + /* { dg-do compile } */ + + extern int baz (void); + extern int foo (void) __attribute__ ((returns_twice)); + + void + bar (_Bool b) + { + int buf[1]; + while (1) + { + _Bool x = 1; + if (b) + baz (); + b = 1; + baz (); + x = 0; + int i; + while (buf[i] && i) + i++; + foo (); + if (!x) + b = 0; + } + }