Commit a26a02d7 by Rafael Avila de Espindola Committed by Rafael Espindola

tree-vrp.c (extract_code_and_val_from_cond): Remove.

2008-04-02  Rafael Espindola  <espindola@google.com>

	* tree-vrp.c (extract_code_and_val_from_cond): Remove.
	(register_edge_assert_for_2): Split the cond argument.
	(register_edge_assert_for_1): Adjust for the change in
	register_edge_assert_for_2.
	(register_edge_assert_for): Split the cond argument.
	(find_switch_asserts): Adjust for the change in
	register_edge_assert_for.

From-SVN: r133827
parent d925aa70
2008-04-02 Rafael Espindola <espindola@google.com>
* tree-vrp.c (extract_code_and_val_from_cond): Remove.
(register_edge_assert_for_2): Split the cond argument.
(register_edge_assert_for_1): Adjust for the change in
register_edge_assert_for_2.
(register_edge_assert_for): Split the cond argument.
(find_switch_asserts): Adjust for the change in
register_edge_assert_for.
2008-04-02 Kai Tietz <kai.tietz@onevision.com> 2008-04-02 Kai Tietz <kai.tietz@onevision.com>
* config.gcc: Add for x86_64-*-mingw* the t-crtfm to tbuild. * config.gcc: Add for x86_64-*-mingw* the t-crtfm to tbuild.
......
...@@ -3681,7 +3681,13 @@ register_new_assert_for (tree name, tree expr, ...@@ -3681,7 +3681,13 @@ register_new_assert_for (tree name, tree expr,
bitmap_set_bit (need_assert_for, SSA_NAME_VERSION (name)); bitmap_set_bit (need_assert_for, SSA_NAME_VERSION (name));
} }
/* Helper function for extract_code_and_val_from_cond */ /* (COND_OP0 COND_CODE COND_OP1) is a predicate which uses NAME.
Extract a suitable test code and value and store them into *CODE_P and
*VAL_P so the predicate is normalized to NAME *CODE_P *VAL_P.
If no extraction was possible, return FALSE, otherwise return TRUE.
If INVERT is true, then we invert the result stored into *CODE_P. */
static bool static bool
extract_code_and_val_from_cond_with_ops (tree name, enum tree_code cond_code, extract_code_and_val_from_cond_with_ops (tree name, enum tree_code cond_code,
...@@ -3742,40 +3748,6 @@ extract_code_and_val_from_cond_with_ops (tree name, enum tree_code cond_code, ...@@ -3742,40 +3748,6 @@ extract_code_and_val_from_cond_with_ops (tree name, enum tree_code cond_code,
*val_p = val; *val_p = val;
return true; return true;
} }
/* COND is a predicate which uses NAME. Extract a suitable test code
and value and store them into *CODE_P and *VAL_P so the predicate
is normalized to NAME *CODE_P *VAL_P.
If no extraction was possible, return FALSE, otherwise return TRUE.
If INVERT is true, then we invert the result stored into *CODE_P. */
static bool
extract_code_and_val_from_cond (tree name, tree cond, bool invert,
enum tree_code *code_p, tree *val_p)
{
enum tree_code comp_code;
tree val;
/* Predicates may be a single SSA name or NAME OP VAL. */
if (cond == name)
{
/* If the predicate is a name, it must be NAME, in which
case we create the predicate NAME == true or
NAME == false accordingly. */
comp_code = EQ_EXPR;
val = invert ? boolean_false_node : boolean_true_node;
*code_p = comp_code;
*val_p = val;
return true;
}
else
return extract_code_and_val_from_cond_with_ops (name, TREE_CODE (cond),
TREE_OPERAND (cond, 0),
TREE_OPERAND (cond, 1),
invert,
code_p, val_p);
}
/* Try to register an edge assertion for SSA name NAME on edge E for /* 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 BSI. the condition COND contributing to the conditional jump pointed to by BSI.
...@@ -3784,13 +3756,17 @@ extract_code_and_val_from_cond (tree name, tree cond, bool invert, ...@@ -3784,13 +3756,17 @@ extract_code_and_val_from_cond (tree name, tree cond, bool invert,
static bool static bool
register_edge_assert_for_2 (tree name, edge e, block_stmt_iterator bsi, register_edge_assert_for_2 (tree name, edge e, block_stmt_iterator bsi,
tree cond, bool invert) enum tree_code cond_code,
tree cond_op0, tree cond_op1, bool invert)
{ {
tree val; tree val;
enum tree_code comp_code; enum tree_code comp_code;
bool retval = false; bool retval = false;
if (!extract_code_and_val_from_cond (name, cond, invert, &comp_code, &val)) if (!extract_code_and_val_from_cond_with_ops (name, cond_code,
cond_op0,
cond_op1,
invert, &comp_code, &val))
return false; return false;
/* Only register an ASSERT_EXPR if NAME was found in the sub-graph /* Only register an ASSERT_EXPR if NAME was found in the sub-graph
...@@ -3917,6 +3893,7 @@ register_edge_assert_for_1 (tree op, enum tree_code code, ...@@ -3917,6 +3893,7 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
{ {
bool retval = false; bool retval = false;
tree op_def, rhs, val; tree op_def, rhs, val;
enum tree_code rhs_code;
/* We only care about SSA_NAMEs. */ /* We only care about SSA_NAMEs. */
if (TREE_CODE (op) != SSA_NAME) if (TREE_CODE (op) != SSA_NAME)
...@@ -3943,6 +3920,7 @@ register_edge_assert_for_1 (tree op, enum tree_code code, ...@@ -3943,6 +3920,7 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
return retval; return retval;
rhs = GIMPLE_STMT_OPERAND (op_def, 1); rhs = GIMPLE_STMT_OPERAND (op_def, 1);
rhs_code = TREE_CODE (rhs);
if (COMPARISON_CLASS_P (rhs)) if (COMPARISON_CLASS_P (rhs))
{ {
...@@ -3951,9 +3929,11 @@ register_edge_assert_for_1 (tree op, enum tree_code code, ...@@ -3951,9 +3929,11 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
tree op1 = TREE_OPERAND (rhs, 1); tree op1 = TREE_OPERAND (rhs, 1);
if (TREE_CODE (op0) == SSA_NAME) if (TREE_CODE (op0) == SSA_NAME)
retval |= register_edge_assert_for_2 (op0, e, bsi, rhs, invert); retval |= register_edge_assert_for_2 (op0, e, bsi, rhs_code, op0, op1,
invert);
if (TREE_CODE (op1) == SSA_NAME) if (TREE_CODE (op1) == SSA_NAME)
retval |= register_edge_assert_for_2 (op1, e, bsi, rhs, invert); retval |= register_edge_assert_for_2 (op1, e, bsi, rhs_code, op0, op1,
invert);
} }
else if ((code == NE_EXPR else if ((code == NE_EXPR
&& (TREE_CODE (rhs) == TRUTH_AND_EXPR && (TREE_CODE (rhs) == TRUTH_AND_EXPR
...@@ -3997,7 +3977,9 @@ register_edge_assert_for_1 (tree op, enum tree_code code, ...@@ -3997,7 +3977,9 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
Return true if an assertion for NAME could be registered. */ Return true if an assertion for NAME could be registered. */
static bool static bool
register_edge_assert_for (tree name, edge e, block_stmt_iterator si, tree cond) register_edge_assert_for (tree name, edge e, block_stmt_iterator si,
enum tree_code cond_code, tree cond_op0,
tree cond_op1)
{ {
tree val; tree val;
enum tree_code comp_code; enum tree_code comp_code;
...@@ -4009,12 +3991,15 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si, tree cond) ...@@ -4009,12 +3991,15 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si, tree cond)
if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name))
return false; return false;
if (!extract_code_and_val_from_cond (name, cond, is_else_edge, if (!extract_code_and_val_from_cond_with_ops (name, cond_code,
&comp_code, &val)) cond_op0, cond_op1,
is_else_edge,
&comp_code, &val))
return false; return false;
/* Register ASSERT_EXPRs for name. */ /* Register ASSERT_EXPRs for name. */
retval |= register_edge_assert_for_2 (name, e, si, cond, is_else_edge); retval |= register_edge_assert_for_2 (name, e, si, cond_code, cond_op0,
cond_op1, is_else_edge);
/* If COND is effectively an equality test of an SSA_NAME against /* If COND is effectively an equality test of an SSA_NAME against
...@@ -4131,8 +4116,17 @@ find_conditional_asserts (basic_block bb, tree last) ...@@ -4131,8 +4116,17 @@ find_conditional_asserts (basic_block bb, tree last)
/* Register the necessary assertions for each operand in the /* Register the necessary assertions for each operand in the
conditional predicate. */ conditional predicate. */
FOR_EACH_SSA_TREE_OPERAND (op, last, iter, SSA_OP_USE) FOR_EACH_SSA_TREE_OPERAND (op, last, iter, SSA_OP_USE)
need_assert |= register_edge_assert_for (op, e, bsi, {
COND_EXPR_COND (last)); tree cond = COND_EXPR_COND (last);
if (op != cond)
need_assert |= register_edge_assert_for (op, e, bsi,
TREE_CODE (cond),
TREE_OPERAND (cond, 0),
TREE_OPERAND (cond, 1));
else
need_assert |= register_edge_assert_for (op, e, bsi, EQ_EXPR, op,
boolean_true_node);
}
} }
/* Finally, indicate that we have found the operands in the /* Finally, indicate that we have found the operands in the
...@@ -4183,7 +4177,7 @@ find_switch_asserts (basic_block bb, tree last) ...@@ -4183,7 +4177,7 @@ find_switch_asserts (basic_block bb, tree last)
{ {
bool need_assert; bool need_assert;
block_stmt_iterator bsi; block_stmt_iterator bsi;
tree op, cond; tree op;
edge e; edge e;
tree vec = SWITCH_LABELS (last), vec2; tree vec = SWITCH_LABELS (last), vec2;
size_t n = TREE_VEC_LENGTH (vec); size_t n = TREE_VEC_LENGTH (vec);
...@@ -4250,14 +4244,17 @@ find_switch_asserts (basic_block bb, tree last) ...@@ -4250,14 +4244,17 @@ find_switch_asserts (basic_block bb, tree last)
/* Register the necessary assertions for the operand in the /* Register the necessary assertions for the operand in the
SWITCH_EXPR. */ SWITCH_EXPR. */
cond = build2 (max ? GE_EXPR : EQ_EXPR, boolean_type_node, need_assert |= register_edge_assert_for (op, e, bsi,
op, fold_convert (TREE_TYPE (op), min)); max ? GE_EXPR : EQ_EXPR,
need_assert |= register_edge_assert_for (op, e, bsi, cond); op,
fold_convert (TREE_TYPE (op),
min));
if (max) if (max)
{ {
cond = build2 (LE_EXPR, boolean_type_node, need_assert |= register_edge_assert_for (op, e, bsi, LE_EXPR,
op, fold_convert (TREE_TYPE (op), max)); op,
need_assert |= register_edge_assert_for (op, e, bsi, cond); fold_convert (TREE_TYPE (op),
max));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment