diff options
author | Jeff Law <law@redhat.com> | 2013-08-21 06:36:36 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2013-08-21 06:36:36 -0600 |
commit | 5562e26eafb432c644b924b79166a0dedb8a2f89 (patch) | |
tree | 8f3794ff3241e02fc16ea5cc1405d408ed1e2fc6 /gcc/tree-vrp.c | |
parent | 8724cfdd3b26fc13de09fe84785acf383b7cee93 (diff) | |
download | gcc-5562e26eafb432c644b924b79166a0dedb8a2f89.zip gcc-5562e26eafb432c644b924b79166a0dedb8a2f89.tar.gz gcc-5562e26eafb432c644b924b79166a0dedb8a2f89.tar.bz2 |
tree-vrp.c (simplify_stmt_for_jump_threading): Try to simplify assignments too.
* tree-vrp.c (simplify_stmt_for_jump_threading): Try to
simplify assignments too. If the RHS collapses to a singleton
range, then return the value for the range.
* gcc.dg/tree-ssa/ssa-vrp-thread-1.c: New test.
From-SVN: r201898
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index ff82591..48b9f7a 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -9273,15 +9273,27 @@ static vec<tree> equiv_stack; static tree simplify_stmt_for_jump_threading (gimple stmt, gimple within_stmt) { - /* We only use VRP information to simplify conditionals. This is - overly conservative, but it's unclear if doing more would be - worth the compile time cost. */ - if (gimple_code (stmt) != GIMPLE_COND) - return NULL; + if (gimple_code (stmt) == GIMPLE_COND) + return vrp_evaluate_conditional (gimple_cond_code (stmt), + gimple_cond_lhs (stmt), + gimple_cond_rhs (stmt), within_stmt); + + if (gimple_code (stmt) == GIMPLE_ASSIGN) + { + value_range_t new_vr = VR_INITIALIZER; + tree lhs = gimple_assign_lhs (stmt); + + if (TREE_CODE (lhs) == SSA_NAME + && (INTEGRAL_TYPE_P (TREE_TYPE (lhs)) + || POINTER_TYPE_P (TREE_TYPE (lhs)))) + { + extract_range_from_assignment (&new_vr, stmt); + if (range_int_cst_singleton_p (&new_vr)) + return new_vr.min; + } + } - return vrp_evaluate_conditional (gimple_cond_code (stmt), - gimple_cond_lhs (stmt), - gimple_cond_rhs (stmt), within_stmt); + return NULL_TREE; } /* Blocks which have more than one predecessor and more than |