This turns the switch (which also requires propagating into ASSERT_EXPRs, otherwise those will end up with released SSA names eventually).
A [3/2] would be to let ASSERT_EXPRs be removed by the propagator which would a) require VRP to fix up its lattice for this task, b) make match-and-simplify not be confused by them during substitute-and-fold folding. This also requires (I think) dealing with symbolic valueizations during substitute-and-fold in a way FRE does (track availability) -- currently propagators restrict themselves to constants due to that (avoid substituting to where the use does not dominate the definition). Re-bootstrap / regtest pending on x86_64-unknown-linux-gnu. Richard. 2016-10-07 Richard Biener <rguent...@suse.de> * tree-ssa-propagate.c (substitute_and_fold_dom_walker::before_dom_children): Do not ignore ASSERT_EXPRs. * tree-vrp.c (remove_range_assertions): Deal with ASSERT_EXPRs that have been propagated into. (vrp_finalize): Enable DCE for substitute_and_fold. Index: gcc/tree-ssa-propagate.c =================================================================== --- gcc/tree-ssa-propagate.c (revision 240855) +++ gcc/tree-ssa-propagate.c (working copy) @@ -1049,15 +1049,6 @@ substitute_and_fold_dom_walker::before_d { bool did_replace; gimple *stmt = gsi_stmt (i); - enum gimple_code code = gimple_code (stmt); - - /* Ignore ASSERT_EXPRs. They are used by VRP to generate - range information for names and they are discarded - afterwards. */ - - if (code == GIMPLE_ASSIGN - && TREE_CODE (gimple_assign_rhs1 (stmt)) == ASSERT_EXPR) - continue; /* No point propagating into a stmt we have a value for we can propagate into all uses. Mark it for removal instead. */ Index: gcc/tree-vrp.c =================================================================== --- gcc/tree-vrp.c (revision 240855) +++ gcc/tree-vrp.c (working copy) @@ -6894,9 +6894,9 @@ remove_range_assertions (void) imm_use_iterator iter; var = ASSERT_EXPR_VAR (rhs); - gcc_assert (TREE_CODE (var) == SSA_NAME); - if (!POINTER_TYPE_P (TREE_TYPE (lhs)) + if (TREE_CODE (var) == SSA_NAME + && !POINTER_TYPE_P (TREE_TYPE (lhs)) && SSA_NAME_RANGE_INFO (lhs)) { if (is_unreachable == -1) @@ -6928,8 +6928,11 @@ remove_range_assertions (void) /* Propagate the RHS into every use of the LHS. */ FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs) - FOR_EACH_IMM_USE_ON_STMT (use_p, iter) - SET_USE (use_p, var); + { + FOR_EACH_IMM_USE_ON_STMT (use_p, iter) + SET_USE (use_p, var); + update_stmt (use_stmt); + } /* And finally, remove the copy, it is not needed. */ gsi_remove (&si, true); @@ -10608,7 +10611,7 @@ vrp_finalize (bool warn_array_bounds_p) } substitute_and_fold (op_with_constant_singleton_value_range, - vrp_fold_stmt, false); + vrp_fold_stmt, true); if (warn_array_bounds && warn_array_bounds_p) check_all_array_refs ();