aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-09-14 11:39:18 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-09-14 11:39:18 +0000
commitf7a39c55dc9b10f45b88547f7ec326639304c518 (patch)
tree6fd00479962b123f3a8374ee9d88447add3a7f1d
parent3ebd25e11b571812971df97c1c589a64f94634a6 (diff)
downloadgcc-f7a39c55dc9b10f45b88547f7ec326639304c518.zip
gcc-f7a39c55dc9b10f45b88547f7ec326639304c518.tar.gz
gcc-f7a39c55dc9b10f45b88547f7ec326639304c518.tar.bz2
tree-vrp.c (register_new_assert_for): Simplify for backward walk.
2012-09-14 Richard Guenther <rguenther@suse.de> * tree-vrp.c (register_new_assert_for): Simplify for backward walk. (find_assert_locations_1): Walk the basic-block backwards, properly add/prune from live. Use live for asserts derived from stmts. From-SVN: r191293
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/tree-vrp.c55
2 files changed, 30 insertions, 33 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2ba65e5..f5da3ab 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2012-09-14 Richard Guenther <rguenther@suse.de>
+
+ * tree-vrp.c (register_new_assert_for): Simplify for backward
+ walk.
+ (find_assert_locations_1): Walk the basic-block backwards,
+ properly add/prune from live. Use live for asserts derived
+ from stmts.
+
2012-09-14 Marc Glisse <marc.glisse@inria.fr>
* tree-ssa-forwprop.c (simplify_bitfield_ref): Call
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index c0a4050..291d899 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4384,24 +4384,7 @@ register_new_assert_for (tree name, tree expr,
&& (loc->expr == expr
|| operand_equal_p (loc->expr, expr, 0)))
{
- /* If the assertion NAME COMP_CODE VAL has already been
- registered at a basic block that dominates DEST_BB, then
- we don't need to insert the same assertion again. Note
- that we don't check strict dominance here to avoid
- replicating the same assertion inside the same basic
- block more than once (e.g., when a pointer is
- dereferenced several times inside a block).
-
- An exception to this rule are edge insertions. If the
- new assertion is to be inserted on edge E, then it will
- dominate all the other insertions that we may want to
- insert in DEST_BB. So, if we are doing an edge
- insertion, don't do this dominance check. */
- if (e == NULL
- && dominated_by_p (CDI_DOMINATORS, dest_bb, loc->bb))
- return;
-
- /* Otherwise, if E is not a critical edge and DEST_BB
+ /* If E is not a critical edge and DEST_BB
dominates the existing location for the assertion, move
the assertion up in the dominance tree by updating its
location information. */
@@ -5439,7 +5422,6 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
{
gimple_stmt_iterator si;
gimple last;
- gimple phi;
bool need_assert;
need_assert = false;
@@ -5462,7 +5444,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
/* Traverse all the statements in BB marking used names and looking
for statements that may infer assertions for their used operands. */
- for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
+ for (si = gsi_last_bb (bb); !gsi_end_p (si); gsi_prev (&si))
{
gimple stmt;
tree op;
@@ -5479,8 +5461,10 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
tree value;
enum tree_code comp_code;
- /* Mark OP in our live bitmap. */
- SET_BIT (live, SSA_NAME_VERSION (op));
+ /* If op is not live beyond this stmt, do not bother to insert
+ asserts for it. */
+ if (!TEST_BIT (live, SSA_NAME_VERSION (op)))
+ continue;
/* If OP is used in such a way that we can infer a value
range for it, and we don't find a previous assertion for
@@ -5520,25 +5504,28 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
}
}
- /* If OP is used only once, namely in this STMT, don't
- bother creating an ASSERT_EXPR for it. Such an
- ASSERT_EXPR would do nothing but increase compile time. */
- if (!has_single_use (op))
- {
- register_new_assert_for (op, op, comp_code, value,
- bb, NULL, si);
- need_assert = true;
- }
+ register_new_assert_for (op, op, comp_code, value, bb, NULL, si);
+ need_assert = true;
}
}
+
+ /* Update live. */
+ FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_USE)
+ SET_BIT (live, SSA_NAME_VERSION (op));
+ FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_DEF)
+ RESET_BIT (live, SSA_NAME_VERSION (op));
}
- /* Traverse all PHI nodes in BB marking used operands. */
+ /* Traverse all PHI nodes in BB, updating live. */
for (si = gsi_start_phis (bb); !gsi_end_p(si); gsi_next (&si))
{
use_operand_p arg_p;
ssa_op_iter i;
- phi = gsi_stmt (si);
+ gimple phi = gsi_stmt (si);
+ tree res = gimple_phi_result (phi);
+
+ if (virtual_operand_p (res))
+ continue;
FOR_EACH_PHI_ARG (arg_p, phi, i, SSA_OP_USE)
{
@@ -5546,6 +5533,8 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
if (TREE_CODE (arg) == SSA_NAME)
SET_BIT (live, SSA_NAME_VERSION (arg));
}
+
+ RESET_BIT (live, SSA_NAME_VERSION (res));
}
return need_assert;