Commit e80d7580 by Rafael Avila de Espindola Committed by Rafael Espindola

tree-flow.h (vrp_evaluate_conditional): Change signature.

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

	* tree-flow.h (vrp_evaluate_conditional): Change signature.
	* tree-ssa-propagate.c (fold_predicate_in): Update call to
	vrp_evaluate_conditional.
	* tree-vrp.c (vrp_evaluate_conditional_warnv): Remove.
        (vrp_evaluate_conditional): Split the cond argument.
        (vrp_visit_cond_stmt): Use vrp_evaluate_conditional_warnv_with_ops.
        (simplify_stmt_for_jump_threading): Update call to
	vrp_evaluate_conditional.

From-SVN: r134625
parent 0e37a1c2
2008-04-24 Rafael Espindola <espindola@google.com>
* tree-flow.h (vrp_evaluate_conditional): Change signature.
* tree-ssa-propagate.c (fold_predicate_in): Update call to
vrp_evaluate_conditional.
* tree-vrp.c (vrp_evaluate_conditional_warnv): Remove.
(vrp_evaluate_conditional): Split the cond argument.
(vrp_visit_cond_stmt): Use vrp_evaluate_conditional_warnv_with_ops.
(simplify_stmt_for_jump_threading): Update call to
vrp_evaluate_conditional.
2008-04-24 Ira Rosen <irar@il.ibm.com> 2008-04-24 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/35982 PR tree-optimization/35982
......
...@@ -944,7 +944,7 @@ tree get_symbol_constant_value (tree); ...@@ -944,7 +944,7 @@ tree get_symbol_constant_value (tree);
tree fold_const_aggregate_ref (tree); tree fold_const_aggregate_ref (tree);
/* In tree-vrp.c */ /* In tree-vrp.c */
tree vrp_evaluate_conditional (tree, tree); tree vrp_evaluate_conditional (enum tree_code, tree, tree, tree);
void simplify_stmt_using_ranges (tree); void simplify_stmt_using_ranges (tree);
/* In tree-ssa-dom.c */ /* In tree-ssa-dom.c */
......
...@@ -1148,7 +1148,17 @@ fold_predicate_in (tree stmt) ...@@ -1148,7 +1148,17 @@ fold_predicate_in (tree stmt)
else else
return false; return false;
val = vrp_evaluate_conditional (*pred_p, stmt); if (TREE_CODE (*pred_p) == SSA_NAME)
val = vrp_evaluate_conditional (EQ_EXPR,
*pred_p,
boolean_true_node,
stmt);
else
val = vrp_evaluate_conditional (TREE_CODE (*pred_p),
TREE_OPERAND (*pred_p, 0),
TREE_OPERAND (*pred_p, 1),
stmt);
if (val) if (val)
{ {
if (modify_stmt_p) if (modify_stmt_p)
......
...@@ -46,7 +46,6 @@ static sbitmap found_in_subgraph; ...@@ -46,7 +46,6 @@ static sbitmap found_in_subgraph;
static int compare_values (tree val1, tree val2); static int compare_values (tree val1, tree val2);
static int compare_values_warnv (tree val1, tree val2, bool *); static int compare_values_warnv (tree val1, tree val2, bool *);
static void vrp_meet (value_range_t *, value_range_t *); static void vrp_meet (value_range_t *, value_range_t *);
static tree vrp_evaluate_conditional_warnv (tree, bool, bool *);
static tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code, static tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
tree, tree, bool, bool *); tree, tree, bool, bool *);
...@@ -5272,64 +5271,7 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0, ...@@ -5272,64 +5271,7 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0,
return NULL_TREE; return NULL_TREE;
} }
/* Given a conditional predicate COND, try to determine if COND yields /* Given (CODE OP0 OP1) within STMT, try to simplify it based on value range
true or false based on the value ranges of its operands. Return
BOOLEAN_TRUE_NODE if the conditional always evaluates to true,
BOOLEAN_FALSE_NODE if the conditional always evaluates to false, and,
NULL if the conditional cannot be evaluated at compile time.
If USE_EQUIV_P is true, the ranges of all the names equivalent with
the operands in COND are used when trying to compute its value.
This is only used during final substitution. During propagation,
we only check the range of each variable and not its equivalents.
Set *STRICT_OVERFLOW_P to indicate whether we relied on an overflow
infinity to produce the result. */
static tree
vrp_evaluate_conditional_warnv (tree cond, bool use_equiv_p,
bool *strict_overflow_p)
{
gcc_assert (TREE_CODE (cond) == SSA_NAME
|| TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison);
if (TREE_CODE (cond) == SSA_NAME)
{
value_range_t *vr;
tree retval;
if (use_equiv_p)
retval = compare_name_with_value (NE_EXPR, cond, boolean_false_node,
strict_overflow_p);
else
{
value_range_t *vr = get_value_range (cond);
retval = compare_range_with_value (NE_EXPR, vr, boolean_false_node,
strict_overflow_p);
}
/* If COND has a known boolean range, return it. */
if (retval)
return retval;
/* Otherwise, if COND has a symbolic range of exactly one value,
return it. */
vr = get_value_range (cond);
if (vr->type == VR_RANGE && vr->min == vr->max)
return vr->min;
}
else
return vrp_evaluate_conditional_warnv_with_ops (TREE_CODE (cond),
TREE_OPERAND (cond, 0),
TREE_OPERAND (cond, 1),
use_equiv_p,
strict_overflow_p);
/* Anything else cannot be computed statically. */
return NULL_TREE;
}
/* Given COND within STMT, try to simplify it based on value range
information. Return NULL if the conditional can not be evaluated. information. Return NULL if the conditional can not be evaluated.
The ranges of all the names equivalent with the operands in COND The ranges of all the names equivalent with the operands in COND
will be used when trying to compute the value. If the result is will be used when trying to compute the value. If the result is
...@@ -5337,13 +5279,17 @@ vrp_evaluate_conditional_warnv (tree cond, bool use_equiv_p, ...@@ -5337,13 +5279,17 @@ vrp_evaluate_conditional_warnv (tree cond, bool use_equiv_p,
appropriate. */ appropriate. */
tree tree
vrp_evaluate_conditional (tree cond, tree stmt) vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, tree stmt)
{ {
bool sop; bool sop;
tree ret; tree ret;
sop = false; sop = false;
ret = vrp_evaluate_conditional_warnv (cond, true, &sop); ret = vrp_evaluate_conditional_warnv_with_ops (code,
op0,
op1,
true,
&sop);
if (ret && sop) if (ret && sop)
{ {
...@@ -5377,8 +5323,8 @@ vrp_evaluate_conditional (tree cond, tree stmt) ...@@ -5377,8 +5323,8 @@ vrp_evaluate_conditional (tree cond, tree stmt)
if (warn_type_limits if (warn_type_limits
&& ret && ret
&& TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison && TREE_CODE_CLASS (code) == tcc_comparison
&& TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME) && TREE_CODE (op0) == SSA_NAME)
{ {
/* If the comparison is being folded and the operand on the LHS /* If the comparison is being folded and the operand on the LHS
is being compared against a constant value that is outside of is being compared against a constant value that is outside of
...@@ -5386,8 +5332,6 @@ vrp_evaluate_conditional (tree cond, tree stmt) ...@@ -5386,8 +5332,6 @@ vrp_evaluate_conditional (tree cond, tree stmt)
always fold regardless of the value of OP0. If -Wtype-limits always fold regardless of the value of OP0. If -Wtype-limits
was specified, emit a warning. */ was specified, emit a warning. */
const char *warnmsg = NULL; const char *warnmsg = NULL;
tree op0 = TREE_OPERAND (cond, 0);
tree op1 = TREE_OPERAND (cond, 1);
tree type = TREE_TYPE (op0); tree type = TREE_TYPE (op0);
value_range_t *vr0 = get_value_range (op0); value_range_t *vr0 = get_value_range (op0);
...@@ -5499,7 +5443,19 @@ vrp_visit_cond_stmt (tree stmt, edge *taken_edge_p) ...@@ -5499,7 +5443,19 @@ vrp_visit_cond_stmt (tree stmt, edge *taken_edge_p)
MICO, TRAMP3D and SPEC2000) showed that doing this results in MICO, TRAMP3D and SPEC2000) showed that doing this results in
4 more predicates folded in SPEC. */ 4 more predicates folded in SPEC. */
sop = false; sop = false;
val = vrp_evaluate_conditional_warnv (cond, false, &sop);
if (TREE_CODE (cond) == SSA_NAME)
val = vrp_evaluate_conditional_warnv_with_ops (EQ_EXPR,
cond,
boolean_true_node,
false,
&sop);
else
val = vrp_evaluate_conditional_warnv_with_ops (TREE_CODE (cond),
TREE_OPERAND (cond, 0),
TREE_OPERAND (cond, 1),
false,
&sop);
if (val) if (val)
{ {
if (!sop) if (!sop)
...@@ -6470,13 +6426,24 @@ static VEC(tree,heap) *stack; ...@@ -6470,13 +6426,24 @@ static VEC(tree,heap) *stack;
static tree static tree
simplify_stmt_for_jump_threading (tree stmt, tree within_stmt) simplify_stmt_for_jump_threading (tree stmt, tree within_stmt)
{ {
tree conditional;
/* We only use VRP information to simplify conditionals. This is /* We only use VRP information to simplify conditionals. This is
overly conservative, but it's unclear if doing more would be overly conservative, but it's unclear if doing more would be
worth the compile time cost. */ worth the compile time cost. */
if (TREE_CODE (stmt) != COND_EXPR) if (TREE_CODE (stmt) != COND_EXPR)
return NULL; return NULL;
return vrp_evaluate_conditional (COND_EXPR_COND (stmt), within_stmt); conditional = COND_EXPR_COND (stmt);
if (TREE_CODE (conditional) == SSA_NAME)
return vrp_evaluate_conditional (EQ_EXPR,
conditional,
boolean_true_node,
within_stmt);
else
return vrp_evaluate_conditional (TREE_CODE (conditional),
TREE_OPERAND (conditional, 0),
TREE_OPERAND (conditional, 1),
within_stmt);
} }
/* Blocks which have more than one predecessor and more than /* Blocks which have more than one predecessor and more than
......
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