The following restores forceful propagation of assert-exprs from SSA names which we know will restore valid IL even if the source is abnormal.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2017-01-27 Richard Biener <rguent...@suse.de> PR tree-optimization/79244 * tree-vrp.c (remove_range_assertions): Forcefully propagate out SSA names even if abnormal. * gcc.dg/torture/pr79244.c: New testcase. Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c (revision 244963) +++ gcc/tree-vrp.c (working copy) @@ -6974,8 +7050,20 @@ remove_range_assertions (void) } } - /* Propagate the RHS into every use of the LHS. */ - replace_uses_by (lhs, var); + /* Propagate the RHS into every use of the LHS. For SSA names + also propagate abnormals as it merely restores the original + IL in this case (an replace_uses_by would assert). */ + if (TREE_CODE (var) == SSA_NAME) + { + imm_use_iterator iter; + use_operand_p use_p; + gimple *use_stmt; + FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs) + FOR_EACH_IMM_USE_ON_STMT (use_p, iter) + SET_USE (use_p, var); + } + else + replace_uses_by (lhs, var); /* And finally, remove the copy, it is not needed. */ gsi_remove (&si, true); Index: gcc/testsuite/gcc.dg/torture/pr79244.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr79244.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr79244.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +long buf[5]; +int bar (void); + +int +foo (int x) +{ + int y = __builtin_setjmp (buf); + while (x != 3 && x && x && x != 2) + x = bar (); + return y; +}