* [PATCH] VRP: simplify assert location check
@ 2014-05-04 3:04 Patrick Palka
2014-05-05 8:28 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2014-05-04 3:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Patrick Palka
We can check if any assertions were found by simply inspecting the
need_assert_for bitmap. This eliminates the need to pass all these
bools around everywhere.
2014-05-03 Patrick Palka <patrick@parcs.ath.cx>
* tree-vrp.c (register_edge_assert_for_1): Change return type
to void.
(register_edge_assert_for, find_conditional_asserts,
find_switch_asserts, find_assert_locations): Likewise.
(insert_range_assertions): Inspect the need_assert_for bitmap.
Bootstrap and regtest on x86_64-unknown-linux-gnu in progress.
---
gcc/tree-vrp.c | 138 ++++++++++++++++++++-------------------------------------
1 file changed, 48 insertions(+), 90 deletions(-)
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 0d18b42..3d24f8e 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4803,7 +4803,7 @@ masked_increment (double_int val, double_int mask, double_int sgnbit,
Invert the condition COND if INVERT is true.
Return true if an assertion is registered. */
-static bool
+static void
register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
unsigned int limit, enum tree_code cond_code,
tree cond_op0, tree cond_op1, bool invert)
@@ -4811,29 +4811,25 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
tree val;
enum tree_code comp_code, def_rhs_code;
gimple def_stmt;
- bool retval = false;
if (limit == 0)
- return false;
+ return;
/* We only care about SSA_NAMEs. */
if (TREE_CODE (name) != SSA_NAME)
- return false;
+ return;
if (!extract_code_and_val_from_cond_with_ops (name, cond_code,
cond_op0,
cond_op1,
invert, &comp_code, &val))
- return false;
+ return;
/* Only register an ASSERT_EXPR if NAME was found in the sub-graph
reachable from E. */
if (live_on_edge (e, name)
&& !has_single_use (name))
- {
- register_new_assert_for (name, name, comp_code, val, NULL, e, bsi);
- retval = true;
- }
+ register_new_assert_for (name, name, comp_code, val, NULL, e, bsi);
/* In the case of NAME <= CST and NAME being defined as
NAME = (unsigned) NAME2 + CST2 we can assert NAME2 >= -CST2
@@ -4894,8 +4890,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
}
register_new_assert_for (name3, tmp, comp_code, val, NULL, e, bsi);
-
- retval = true;
}
/* If name2 is used later, create an ASSERT_EXPR for it. */
@@ -4925,8 +4919,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
}
register_new_assert_for (name2, tmp, comp_code, val, NULL, e, bsi);
-
- retval = true;
}
}
@@ -4964,7 +4956,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
cst = int_const_binop (code, val, cst);
register_new_assert_for (name2, name2, comp_code, cst,
NULL, e, bsi);
- retval = true;
}
}
}
@@ -5028,8 +5019,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
register_new_assert_for (name2, tmp, new_comp_code, cst, NULL,
e, bsi);
-
- retval = true;
}
}
@@ -5108,7 +5097,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
register_new_assert_for (name2, tmp, new_comp_code, new_val,
NULL, e, bsi);
- retval = true;
}
}
@@ -5129,8 +5117,7 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
&& TREE_CODE (TREE_TYPE (val)) == INTEGER_TYPE
&& TYPE_UNSIGNED (TREE_TYPE (val))
&& TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt)))
- > prec
- && !retval))
+ > prec))
{
name2 = gimple_assign_rhs1 (def_stmt);
if (rhs_code == BIT_AND_EXPR)
@@ -5358,7 +5345,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
register_new_assert_for (names[i], tmp, LE_EXPR,
new_val, NULL, e, bsi);
- retval = true;
}
}
}
@@ -5370,7 +5356,7 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
def_stmt = SSA_NAME_DEF_STMT (name);
if (!is_gimple_assign (def_stmt))
- return retval;
+ return;
def_rhs_code = gimple_assign_rhs_code (def_stmt);
@@ -5385,10 +5371,10 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
tree op0 = gimple_assign_rhs1 (def_stmt);
tree op1 = gimple_assign_rhs2 (def_stmt);
tree zero = build_zero_cst (TREE_TYPE (val));
- retval |= register_edge_assert_for_1 (op0, e, bsi, limit - 1,
- NE_EXPR, op0, zero, false);
- retval |= register_edge_assert_for_1 (op1, e, bsi, limit - 1,
- NE_EXPR, op1, zero, false);
+ register_edge_assert_for_1 (op0, e, bsi, limit - 1,
+ NE_EXPR, op0, zero, false);
+ register_edge_assert_for_1 (op1, e, bsi, limit - 1,
+ NE_EXPR, op1, zero, false);
}
/* In the case of NAME == 0 or NAME != 1, for BIT_IOR_EXPR defining
@@ -5404,10 +5390,10 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
tree op0 = gimple_assign_rhs1 (def_stmt);
tree op1 = gimple_assign_rhs2 (def_stmt);
tree zero = build_zero_cst (TREE_TYPE (val));
- retval |= register_edge_assert_for_1 (op0, e, bsi, limit - 1,
- EQ_EXPR, op0, zero, false);
- retval |= register_edge_assert_for_1 (op1, e, bsi, limit - 1,
- EQ_EXPR, op1, zero, false);
+ register_edge_assert_for_1 (op0, e, bsi, limit - 1,
+ EQ_EXPR, op0, zero, false);
+ register_edge_assert_for_1 (op1, e, bsi, limit - 1,
+ EQ_EXPR, op1, zero, false);
}
if (def_rhs_code == BIT_NOT_EXPR
@@ -5417,8 +5403,8 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
/* Recurse, inverting VAL. */
tree rhs = gimple_assign_rhs1 (def_stmt);
tree new_val = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (val), val);
- retval |= register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
- comp_code, rhs, new_val, false);
+ register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
+ comp_code, rhs, new_val, false);
}
/* In the case of NAME == [01] or NAME != [01], if NAME's defining statement
@@ -5434,18 +5420,18 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
if ((comp_code == EQ_EXPR && integer_zerop (val))
|| (comp_code == NE_EXPR && integer_onep (val)))
invert = true;
- retval |= register_edge_assert_for_1 (op0, e, bsi, limit - 1,
- def_rhs_code, op0, op1, invert);
- retval |= register_edge_assert_for_1 (op1, e, bsi, limit - 1,
- def_rhs_code, op0, op1, invert);
+ register_edge_assert_for_1 (op0, e, bsi, limit - 1,
+ def_rhs_code, op0, op1, invert);
+ register_edge_assert_for_1 (op1, e, bsi, limit - 1,
+ def_rhs_code, op0, op1, invert);
}
if (def_rhs_code == SSA_NAME)
{
/* Recurse through the copy. */
tree rhs = gimple_assign_rhs1 (def_stmt);
- retval |= register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
- comp_code, rhs, val, false);
+ register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
+ comp_code, rhs, val, false);
}
if (CONVERT_EXPR_CODE_P (def_rhs_code)
@@ -5465,36 +5451,31 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
&& TYPE_UNSIGNED (TREE_TYPE (val)))))
{
tree new_val = fold_build1 (CONVERT_EXPR, TREE_TYPE (rhs), val);
- retval |= register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
- comp_code, rhs, new_val, false);
+ register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
+ comp_code, rhs, new_val, false);
}
}
-
- return retval;
}
/* Try to register an edge assertion for SSA name NAME on edge E for
the condition COND contributing to the conditional jump pointed to by SI.
Return true if an assertion for NAME could be registered. */
-static bool
+static void
register_edge_assert_for (tree name, edge e, gimple_stmt_iterator si,
enum tree_code cond_code, tree cond_op0,
tree cond_op1)
{
- bool retval;
bool is_else_edge = (e->flags & EDGE_FALSE_VALUE) != 0;
/* Do not attempt to infer anything in names that flow through
abnormal edges. */
if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name))
- return false;
+ return;
/* Register ASSERT_EXPRs for name. */
- retval = register_edge_assert_for_1 (name, e, si, 5, cond_code,
- cond_op0, cond_op1, is_else_edge);
-
- return retval;
+ register_edge_assert_for_1 (name, e, si, 5, cond_code,
+ cond_op0, cond_op1, is_else_edge);
}
@@ -5531,12 +5512,10 @@ find_conditional_asserts (basic_block bb, gimple last)
/* Register the necessary assertions for each operand in the
conditional predicate. */
FOR_EACH_SSA_TREE_OPERAND (op, last, iter, SSA_OP_USE)
- {
- need_assert |= register_edge_assert_for (op, e, bsi,
- gimple_cond_code (last),
- gimple_cond_lhs (last),
- gimple_cond_rhs (last));
- }
+ register_edge_assert_for (op, e, bsi,
+ gimple_cond_code (last),
+ gimple_cond_lhs (last),
+ gimple_cond_rhs (last));
}
return need_assert;
@@ -5584,10 +5563,9 @@ compare_case_labels (const void *p1, const void *p2)
the predicate operands, an assert location node is added to the
list of assertions for the corresponding operands. */
-static bool
+static void
find_switch_asserts (basic_block bb, gimple last)
{
- bool need_assert;
gimple_stmt_iterator bsi;
tree op;
edge e;
@@ -5600,11 +5578,10 @@ find_switch_asserts (basic_block bb, gimple last)
volatile unsigned int idx;
#endif
- need_assert = false;
bsi = gsi_for_stmt (last);
op = gimple_switch_index (last);
if (TREE_CODE (op) != SSA_NAME)
- return false;
+ return;
/* Build a vector of case labels sorted by destination label. */
ci = XNEWVEC (struct case_info, n);
@@ -5651,22 +5628,14 @@ find_switch_asserts (basic_block bb, gimple last)
/* Register the necessary assertions for the operand in the
SWITCH_EXPR. */
- need_assert |= register_edge_assert_for (op, e, bsi,
- max ? GE_EXPR : EQ_EXPR,
- op,
- fold_convert (TREE_TYPE (op),
- min));
+ register_edge_assert_for (op, e, bsi, max ? GE_EXPR : EQ_EXPR, op,
+ fold_convert (TREE_TYPE (op), min));
if (max)
- {
- need_assert |= register_edge_assert_for (op, e, bsi, LE_EXPR,
- op,
- fold_convert (TREE_TYPE (op),
- max));
- }
+ register_edge_assert_for (op, e, bsi, LE_EXPR, op,
+ fold_convert (TREE_TYPE (op), max));
}
XDELETEVEC (ci);
- return need_assert;
}
@@ -5733,14 +5702,12 @@ find_switch_asserts (basic_block bb, gimple last)
for which we need to generate ASSERT_EXPRs. Those assertions are
inserted by process_assert_insertions. */
-static bool
+static void
find_assert_locations_1 (basic_block bb, sbitmap live)
{
gimple_stmt_iterator si;
gimple last;
- bool need_assert;
- need_assert = false;
last = last_stmt (bb);
/* If BB's last statement is a conditional statement involving integer
@@ -5749,14 +5716,14 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
&& gimple_code (last) == GIMPLE_COND
&& !fp_predicate (last)
&& !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
- need_assert |= find_conditional_asserts (bb, last);
+ find_conditional_asserts (bb, last);
/* If BB's last statement is a switch statement involving integer
operands, determine if we need to add ASSERT_EXPRs. */
if (last
&& gimple_code (last) == GIMPLE_SWITCH
&& !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
- need_assert |= find_switch_asserts (bb, last);
+ find_switch_asserts (bb, last);
/* Traverse all the statements in BB marking used names and looking
for statements that may infer assertions for their used operands. */
@@ -5812,16 +5779,12 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
operand of the NOP_EXPR after SI, not after the
conversion. */
if (! has_single_use (t))
- {
- register_new_assert_for (t, t, comp_code, value,
- bb, NULL, si);
- need_assert = true;
- }
+ register_new_assert_for (t, t, comp_code, value,
+ bb, NULL, si);
}
}
register_new_assert_for (op, op, comp_code, value, bb, NULL, si);
- need_assert = true;
}
}
@@ -5852,22 +5815,19 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
bitmap_clear_bit (live, SSA_NAME_VERSION (res));
}
-
- return need_assert;
}
/* Do an RPO walk over the function computing SSA name liveness
on-the-fly and deciding on assert expressions to insert.
Returns true if there are assert expressions to be inserted. */
-static bool
+static void
find_assert_locations (void)
{
int *rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
int *bb_rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
int *last_rpo = XCNEWVEC (int, last_basic_block_for_fn (cfun));
int rpo_cnt, i;
- bool need_asserts;
live = XCNEWVEC (sbitmap, last_basic_block_for_fn (cfun));
rpo_cnt = pre_and_rev_post_order_compute (NULL, rpo, false);
@@ -5901,7 +5861,6 @@ find_assert_locations (void)
}
}
- need_asserts = false;
for (i = rpo_cnt - 1; i >= 0; --i)
{
basic_block bb = BASIC_BLOCK_FOR_FN (cfun, rpo[i]);
@@ -5916,7 +5875,7 @@ find_assert_locations (void)
/* Process BB and update the live information with uses in
this block. */
- need_asserts |= find_assert_locations_1 (bb, live[rpo[i]]);
+ find_assert_locations_1 (bb, live[rpo[i]]);
/* Merge liveness into the predecessor blocks and free it. */
if (!bitmap_empty_p (live[rpo[i]]))
@@ -5967,8 +5926,6 @@ find_assert_locations (void)
if (live[i])
sbitmap_free (live[i]);
XDELETEVEC (live);
-
- return need_asserts;
}
/* Create an ASSERT_EXPR for NAME and insert it in the location
@@ -6104,7 +6061,8 @@ insert_range_assertions (void)
calculate_dominance_info (CDI_DOMINATORS);
- if (find_assert_locations ())
+ find_assert_locations ();
+ if (!bitmap_empty_p (need_assert_for))
{
process_assert_insertions ();
update_ssa (TODO_update_ssa_no_phi);
--
1.9.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] VRP: simplify assert location check
2014-05-04 3:04 [PATCH] VRP: simplify assert location check Patrick Palka
@ 2014-05-05 8:28 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2014-05-05 8:28 UTC (permalink / raw)
To: Patrick Palka; +Cc: GCC Patches
On Sun, May 4, 2014 at 5:03 AM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> We can check if any assertions were found by simply inspecting the
> need_assert_for bitmap. This eliminates the need to pass all these
> bools around everywhere.
>
> 2014-05-03 Patrick Palka <patrick@parcs.ath.cx>
>
> * tree-vrp.c (register_edge_assert_for_1): Change return type
> to void.
> (register_edge_assert_for, find_conditional_asserts,
> find_switch_asserts, find_assert_locations): Likewise.
> (insert_range_assertions): Inspect the need_assert_for bitmap.
>
> Bootstrap and regtest on x86_64-unknown-linux-gnu in progress.
Ok if that passes.
Thanks,
Richard.
> ---
> gcc/tree-vrp.c | 138 ++++++++++++++++++++-------------------------------------
> 1 file changed, 48 insertions(+), 90 deletions(-)
>
> diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
> index 0d18b42..3d24f8e 100644
> --- a/gcc/tree-vrp.c
> +++ b/gcc/tree-vrp.c
> @@ -4803,7 +4803,7 @@ masked_increment (double_int val, double_int mask, double_int sgnbit,
> Invert the condition COND if INVERT is true.
> Return true if an assertion is registered. */
>
> -static bool
> +static void
> register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> unsigned int limit, enum tree_code cond_code,
> tree cond_op0, tree cond_op1, bool invert)
> @@ -4811,29 +4811,25 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> tree val;
> enum tree_code comp_code, def_rhs_code;
> gimple def_stmt;
> - bool retval = false;
>
> if (limit == 0)
> - return false;
> + return;
>
> /* We only care about SSA_NAMEs. */
> if (TREE_CODE (name) != SSA_NAME)
> - return false;
> + return;
>
> if (!extract_code_and_val_from_cond_with_ops (name, cond_code,
> cond_op0,
> cond_op1,
> invert, &comp_code, &val))
> - return false;
> + return;
>
> /* Only register an ASSERT_EXPR if NAME was found in the sub-graph
> reachable from E. */
> if (live_on_edge (e, name)
> && !has_single_use (name))
> - {
> - register_new_assert_for (name, name, comp_code, val, NULL, e, bsi);
> - retval = true;
> - }
> + register_new_assert_for (name, name, comp_code, val, NULL, e, bsi);
>
> /* In the case of NAME <= CST and NAME being defined as
> NAME = (unsigned) NAME2 + CST2 we can assert NAME2 >= -CST2
> @@ -4894,8 +4890,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> }
>
> register_new_assert_for (name3, tmp, comp_code, val, NULL, e, bsi);
> -
> - retval = true;
> }
>
> /* If name2 is used later, create an ASSERT_EXPR for it. */
> @@ -4925,8 +4919,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> }
>
> register_new_assert_for (name2, tmp, comp_code, val, NULL, e, bsi);
> -
> - retval = true;
> }
> }
>
> @@ -4964,7 +4956,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> cst = int_const_binop (code, val, cst);
> register_new_assert_for (name2, name2, comp_code, cst,
> NULL, e, bsi);
> - retval = true;
> }
> }
> }
> @@ -5028,8 +5019,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
>
> register_new_assert_for (name2, tmp, new_comp_code, cst, NULL,
> e, bsi);
> -
> - retval = true;
> }
> }
>
> @@ -5108,7 +5097,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
>
> register_new_assert_for (name2, tmp, new_comp_code, new_val,
> NULL, e, bsi);
> - retval = true;
> }
> }
>
> @@ -5129,8 +5117,7 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> && TREE_CODE (TREE_TYPE (val)) == INTEGER_TYPE
> && TYPE_UNSIGNED (TREE_TYPE (val))
> && TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt)))
> - > prec
> - && !retval))
> + > prec))
> {
> name2 = gimple_assign_rhs1 (def_stmt);
> if (rhs_code == BIT_AND_EXPR)
> @@ -5358,7 +5345,6 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
>
> register_new_assert_for (names[i], tmp, LE_EXPR,
> new_val, NULL, e, bsi);
> - retval = true;
> }
> }
> }
> @@ -5370,7 +5356,7 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
>
> def_stmt = SSA_NAME_DEF_STMT (name);
> if (!is_gimple_assign (def_stmt))
> - return retval;
> + return;
>
> def_rhs_code = gimple_assign_rhs_code (def_stmt);
>
> @@ -5385,10 +5371,10 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> tree op0 = gimple_assign_rhs1 (def_stmt);
> tree op1 = gimple_assign_rhs2 (def_stmt);
> tree zero = build_zero_cst (TREE_TYPE (val));
> - retval |= register_edge_assert_for_1 (op0, e, bsi, limit - 1,
> - NE_EXPR, op0, zero, false);
> - retval |= register_edge_assert_for_1 (op1, e, bsi, limit - 1,
> - NE_EXPR, op1, zero, false);
> + register_edge_assert_for_1 (op0, e, bsi, limit - 1,
> + NE_EXPR, op0, zero, false);
> + register_edge_assert_for_1 (op1, e, bsi, limit - 1,
> + NE_EXPR, op1, zero, false);
> }
>
> /* In the case of NAME == 0 or NAME != 1, for BIT_IOR_EXPR defining
> @@ -5404,10 +5390,10 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> tree op0 = gimple_assign_rhs1 (def_stmt);
> tree op1 = gimple_assign_rhs2 (def_stmt);
> tree zero = build_zero_cst (TREE_TYPE (val));
> - retval |= register_edge_assert_for_1 (op0, e, bsi, limit - 1,
> - EQ_EXPR, op0, zero, false);
> - retval |= register_edge_assert_for_1 (op1, e, bsi, limit - 1,
> - EQ_EXPR, op1, zero, false);
> + register_edge_assert_for_1 (op0, e, bsi, limit - 1,
> + EQ_EXPR, op0, zero, false);
> + register_edge_assert_for_1 (op1, e, bsi, limit - 1,
> + EQ_EXPR, op1, zero, false);
> }
>
> if (def_rhs_code == BIT_NOT_EXPR
> @@ -5417,8 +5403,8 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> /* Recurse, inverting VAL. */
> tree rhs = gimple_assign_rhs1 (def_stmt);
> tree new_val = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (val), val);
> - retval |= register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
> - comp_code, rhs, new_val, false);
> + register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
> + comp_code, rhs, new_val, false);
> }
>
> /* In the case of NAME == [01] or NAME != [01], if NAME's defining statement
> @@ -5434,18 +5420,18 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> if ((comp_code == EQ_EXPR && integer_zerop (val))
> || (comp_code == NE_EXPR && integer_onep (val)))
> invert = true;
> - retval |= register_edge_assert_for_1 (op0, e, bsi, limit - 1,
> - def_rhs_code, op0, op1, invert);
> - retval |= register_edge_assert_for_1 (op1, e, bsi, limit - 1,
> - def_rhs_code, op0, op1, invert);
> + register_edge_assert_for_1 (op0, e, bsi, limit - 1,
> + def_rhs_code, op0, op1, invert);
> + register_edge_assert_for_1 (op1, e, bsi, limit - 1,
> + def_rhs_code, op0, op1, invert);
> }
>
> if (def_rhs_code == SSA_NAME)
> {
> /* Recurse through the copy. */
> tree rhs = gimple_assign_rhs1 (def_stmt);
> - retval |= register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
> - comp_code, rhs, val, false);
> + register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
> + comp_code, rhs, val, false);
> }
>
> if (CONVERT_EXPR_CODE_P (def_rhs_code)
> @@ -5465,36 +5451,31 @@ register_edge_assert_for_1 (tree name, edge e, gimple_stmt_iterator bsi,
> && TYPE_UNSIGNED (TREE_TYPE (val)))))
> {
> tree new_val = fold_build1 (CONVERT_EXPR, TREE_TYPE (rhs), val);
> - retval |= register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
> - comp_code, rhs, new_val, false);
> + register_edge_assert_for_1 (rhs, e, bsi, limit - 1,
> + comp_code, rhs, new_val, false);
> }
> }
> -
> - return retval;
> }
>
> /* Try to register an edge assertion for SSA name NAME on edge E for
> the condition COND contributing to the conditional jump pointed to by SI.
> Return true if an assertion for NAME could be registered. */
>
> -static bool
> +static void
> register_edge_assert_for (tree name, edge e, gimple_stmt_iterator si,
> enum tree_code cond_code, tree cond_op0,
> tree cond_op1)
> {
> - bool retval;
> bool is_else_edge = (e->flags & EDGE_FALSE_VALUE) != 0;
>
> /* Do not attempt to infer anything in names that flow through
> abnormal edges. */
> if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name))
> - return false;
> + return;
>
> /* Register ASSERT_EXPRs for name. */
> - retval = register_edge_assert_for_1 (name, e, si, 5, cond_code,
> - cond_op0, cond_op1, is_else_edge);
> -
> - return retval;
> + register_edge_assert_for_1 (name, e, si, 5, cond_code,
> + cond_op0, cond_op1, is_else_edge);
> }
>
>
> @@ -5531,12 +5512,10 @@ find_conditional_asserts (basic_block bb, gimple last)
> /* Register the necessary assertions for each operand in the
> conditional predicate. */
> FOR_EACH_SSA_TREE_OPERAND (op, last, iter, SSA_OP_USE)
> - {
> - need_assert |= register_edge_assert_for (op, e, bsi,
> - gimple_cond_code (last),
> - gimple_cond_lhs (last),
> - gimple_cond_rhs (last));
> - }
> + register_edge_assert_for (op, e, bsi,
> + gimple_cond_code (last),
> + gimple_cond_lhs (last),
> + gimple_cond_rhs (last));
> }
>
> return need_assert;
> @@ -5584,10 +5563,9 @@ compare_case_labels (const void *p1, const void *p2)
> the predicate operands, an assert location node is added to the
> list of assertions for the corresponding operands. */
>
> -static bool
> +static void
> find_switch_asserts (basic_block bb, gimple last)
> {
> - bool need_assert;
> gimple_stmt_iterator bsi;
> tree op;
> edge e;
> @@ -5600,11 +5578,10 @@ find_switch_asserts (basic_block bb, gimple last)
> volatile unsigned int idx;
> #endif
>
> - need_assert = false;
> bsi = gsi_for_stmt (last);
> op = gimple_switch_index (last);
> if (TREE_CODE (op) != SSA_NAME)
> - return false;
> + return;
>
> /* Build a vector of case labels sorted by destination label. */
> ci = XNEWVEC (struct case_info, n);
> @@ -5651,22 +5628,14 @@ find_switch_asserts (basic_block bb, gimple last)
>
> /* Register the necessary assertions for the operand in the
> SWITCH_EXPR. */
> - need_assert |= register_edge_assert_for (op, e, bsi,
> - max ? GE_EXPR : EQ_EXPR,
> - op,
> - fold_convert (TREE_TYPE (op),
> - min));
> + register_edge_assert_for (op, e, bsi, max ? GE_EXPR : EQ_EXPR, op,
> + fold_convert (TREE_TYPE (op), min));
> if (max)
> - {
> - need_assert |= register_edge_assert_for (op, e, bsi, LE_EXPR,
> - op,
> - fold_convert (TREE_TYPE (op),
> - max));
> - }
> + register_edge_assert_for (op, e, bsi, LE_EXPR, op,
> + fold_convert (TREE_TYPE (op), max));
> }
>
> XDELETEVEC (ci);
> - return need_assert;
> }
>
>
> @@ -5733,14 +5702,12 @@ find_switch_asserts (basic_block bb, gimple last)
> for which we need to generate ASSERT_EXPRs. Those assertions are
> inserted by process_assert_insertions. */
>
> -static bool
> +static void
> find_assert_locations_1 (basic_block bb, sbitmap live)
> {
> gimple_stmt_iterator si;
> gimple last;
> - bool need_assert;
>
> - need_assert = false;
> last = last_stmt (bb);
>
> /* If BB's last statement is a conditional statement involving integer
> @@ -5749,14 +5716,14 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
> && gimple_code (last) == GIMPLE_COND
> && !fp_predicate (last)
> && !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
> - need_assert |= find_conditional_asserts (bb, last);
> + find_conditional_asserts (bb, last);
>
> /* If BB's last statement is a switch statement involving integer
> operands, determine if we need to add ASSERT_EXPRs. */
> if (last
> && gimple_code (last) == GIMPLE_SWITCH
> && !ZERO_SSA_OPERANDS (last, SSA_OP_USE))
> - need_assert |= find_switch_asserts (bb, last);
> + find_switch_asserts (bb, last);
>
> /* Traverse all the statements in BB marking used names and looking
> for statements that may infer assertions for their used operands. */
> @@ -5812,16 +5779,12 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
> operand of the NOP_EXPR after SI, not after the
> conversion. */
> if (! has_single_use (t))
> - {
> - register_new_assert_for (t, t, comp_code, value,
> - bb, NULL, si);
> - need_assert = true;
> - }
> + register_new_assert_for (t, t, comp_code, value,
> + bb, NULL, si);
> }
> }
>
> register_new_assert_for (op, op, comp_code, value, bb, NULL, si);
> - need_assert = true;
> }
> }
>
> @@ -5852,22 +5815,19 @@ find_assert_locations_1 (basic_block bb, sbitmap live)
>
> bitmap_clear_bit (live, SSA_NAME_VERSION (res));
> }
> -
> - return need_assert;
> }
>
> /* Do an RPO walk over the function computing SSA name liveness
> on-the-fly and deciding on assert expressions to insert.
> Returns true if there are assert expressions to be inserted. */
>
> -static bool
> +static void
> find_assert_locations (void)
> {
> int *rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
> int *bb_rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
> int *last_rpo = XCNEWVEC (int, last_basic_block_for_fn (cfun));
> int rpo_cnt, i;
> - bool need_asserts;
>
> live = XCNEWVEC (sbitmap, last_basic_block_for_fn (cfun));
> rpo_cnt = pre_and_rev_post_order_compute (NULL, rpo, false);
> @@ -5901,7 +5861,6 @@ find_assert_locations (void)
> }
> }
>
> - need_asserts = false;
> for (i = rpo_cnt - 1; i >= 0; --i)
> {
> basic_block bb = BASIC_BLOCK_FOR_FN (cfun, rpo[i]);
> @@ -5916,7 +5875,7 @@ find_assert_locations (void)
>
> /* Process BB and update the live information with uses in
> this block. */
> - need_asserts |= find_assert_locations_1 (bb, live[rpo[i]]);
> + find_assert_locations_1 (bb, live[rpo[i]]);
>
> /* Merge liveness into the predecessor blocks and free it. */
> if (!bitmap_empty_p (live[rpo[i]]))
> @@ -5967,8 +5926,6 @@ find_assert_locations (void)
> if (live[i])
> sbitmap_free (live[i]);
> XDELETEVEC (live);
> -
> - return need_asserts;
> }
>
> /* Create an ASSERT_EXPR for NAME and insert it in the location
> @@ -6104,7 +6061,8 @@ insert_range_assertions (void)
>
> calculate_dominance_info (CDI_DOMINATORS);
>
> - if (find_assert_locations ())
> + find_assert_locations ();
> + if (!bitmap_empty_p (need_assert_for))
> {
> process_assert_insertions ();
> update_ssa (TODO_update_ssa_no_phi);
> --
> 1.9.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-05 8:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-04 3:04 [PATCH] VRP: simplify assert location check Patrick Palka
2014-05-05 8:28 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).