Commit 6b99f156 by Jan Hubicka Committed by Jan Hubicka

tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges): Break out from ...

	* tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges):
	Break out from ...
	(vrp_evaluate_conditional_warnv_with_ops): ... this one.  Add
	using_ranges argument.
	(vrp_evaluate_conditional): Avoid bogus warning for type range.
	(vrp_visit_cond_stmt): Update call of
	vrp_evaluate_conditional_warnv_with_ops

From-SVN: r139981
parent 4db15d75
2008-09-04 Jan Hubicka <jh@suse.cz> 2008-09-04 Jan Hubicka <jh@suse.cz>
* tree-vrp.c (vrp_evaluate_conditional_warnv_with_ops_using_ranges):
Break out from ...
(vrp_evaluate_conditional_warnv_with_ops): ... this one. Add
using_ranges argument.
(vrp_evaluate_conditional): Avoid bogus warning for type range.
(vrp_visit_cond_stmt): Update call of
vrp_evaluate_conditional_warnv_with_ops
2008-09-04 Jan Hubicka <jh@suse.cz>
PR tree-optimization/37345 PR tree-optimization/37345
PR tree-optimization/37358 PR tree-optimization/37358
PR tree-optimization/37357 PR tree-optimization/37357
......
...@@ -57,7 +57,8 @@ static int compare_values (tree val1, tree val2); ...@@ -57,7 +57,8 @@ 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_with_ops (enum tree_code, static tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
tree, tree, bool, bool *); tree, tree, bool, bool *,
bool *);
/* Location information for ASSERT_EXPRs. Each instance of this /* Location information for ASSERT_EXPRs. Each instance of this
structure describes an ASSERT_EXPR for an SSA name. Since a single structure describes an ASSERT_EXPR for an SSA name. Since a single
...@@ -2905,7 +2906,8 @@ extract_range_from_comparison (value_range_t *vr, enum tree_code code, ...@@ -2905,7 +2906,8 @@ extract_range_from_comparison (value_range_t *vr, enum tree_code code,
bool sop = false; bool sop = false;
tree val; tree val;
val = vrp_evaluate_conditional_warnv_with_ops (code, op0, op1, false, &sop); val = vrp_evaluate_conditional_warnv_with_ops (code, op0, op1, false, &sop,
NULL);
/* A disadvantage of using a special infinity as an overflow /* A disadvantage of using a special infinity as an overflow
representation is that we lose the ability to record overflow representation is that we lose the ability to record overflow
...@@ -5447,13 +5449,39 @@ compare_names (enum tree_code comp, tree n1, tree n2, ...@@ -5447,13 +5449,39 @@ compare_names (enum tree_code comp, tree n1, tree n2,
return NULL_TREE; return NULL_TREE;
} }
/* Helper function for vrp_evaluate_conditional_warnv. */
static tree
vrp_evaluate_conditional_warnv_with_ops_using_ranges (enum tree_code code,
tree op0, tree op1,
bool * strict_overflow_p)
{
value_range_t *vr0, *vr1;
vr0 = (TREE_CODE (op0) == SSA_NAME) ? get_value_range (op0) : NULL;
vr1 = (TREE_CODE (op1) == SSA_NAME) ? get_value_range (op1) : NULL;
if (vr0 && vr1)
return compare_ranges (code, vr0, vr1, strict_overflow_p);
else if (vr0 && vr1 == NULL)
return compare_range_with_value (code, vr0, op1, strict_overflow_p);
else if (vr0 == NULL && vr1)
return (compare_range_with_value
(swap_tree_comparison (code), vr1, op0, strict_overflow_p));
return NULL;
}
/* Helper function for vrp_evaluate_conditional_warnv. */ /* Helper function for vrp_evaluate_conditional_warnv. */
static tree static tree
vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0, vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0,
tree op1, bool use_equiv_p, tree op1, bool use_equiv_p,
bool *strict_overflow_p) bool *strict_overflow_p, bool *only_ranges)
{ {
tree ret;
if (only_ranges)
*only_ranges = true;
/* We only deal with integral and pointer types. */ /* We only deal with integral and pointer types. */
if (!INTEGRAL_TYPE_P (TREE_TYPE (op0)) if (!INTEGRAL_TYPE_P (TREE_TYPE (op0))
&& !POINTER_TYPE_P (TREE_TYPE (op0))) && !POINTER_TYPE_P (TREE_TYPE (op0)))
...@@ -5461,6 +5489,11 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0, ...@@ -5461,6 +5489,11 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0,
if (use_equiv_p) if (use_equiv_p)
{ {
if (only_ranges
&& (ret = vrp_evaluate_conditional_warnv_with_ops_using_ranges
(code, op0, op1, strict_overflow_p)))
return ret;
*only_ranges = false;
if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME) if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == SSA_NAME)
return compare_names (code, op0, op1, strict_overflow_p); return compare_names (code, op0, op1, strict_overflow_p);
else if (TREE_CODE (op0) == SSA_NAME) else if (TREE_CODE (op0) == SSA_NAME)
...@@ -5470,20 +5503,8 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0, ...@@ -5470,20 +5503,8 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0,
(swap_tree_comparison (code), op1, op0, strict_overflow_p)); (swap_tree_comparison (code), op1, op0, strict_overflow_p));
} }
else else
{ return vrp_evaluate_conditional_warnv_with_ops_using_ranges (code, op0, op1,
value_range_t *vr0, *vr1; strict_overflow_p);
vr0 = (TREE_CODE (op0) == SSA_NAME) ? get_value_range (op0) : NULL;
vr1 = (TREE_CODE (op1) == SSA_NAME) ? get_value_range (op1) : NULL;
if (vr0 && vr1)
return compare_ranges (code, vr0, vr1, strict_overflow_p);
else if (vr0 && vr1 == NULL)
return compare_range_with_value (code, vr0, op1, strict_overflow_p);
else if (vr0 == NULL && vr1)
return (compare_range_with_value
(swap_tree_comparison (code), vr1, op0, strict_overflow_p));
}
return NULL_TREE; return NULL_TREE;
} }
...@@ -5499,9 +5520,11 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt) ...@@ -5499,9 +5520,11 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt)
{ {
bool sop; bool sop;
tree ret; tree ret;
bool only_ranges;
sop = false; sop = false;
ret = vrp_evaluate_conditional_warnv_with_ops (code, op0, op1, true, &sop); ret = vrp_evaluate_conditional_warnv_with_ops (code, op0, op1, true, &sop,
&only_ranges);
if (ret && sop) if (ret && sop)
{ {
...@@ -5534,7 +5557,7 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt) ...@@ -5534,7 +5557,7 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt)
} }
if (warn_type_limits if (warn_type_limits
&& ret && ret && only_ranges
&& TREE_CODE_CLASS (code) == tcc_comparison && TREE_CODE_CLASS (code) == tcc_comparison
&& TREE_CODE (op0) == SSA_NAME) && TREE_CODE (op0) == SSA_NAME)
{ {
...@@ -5658,7 +5681,7 @@ vrp_visit_cond_stmt (gimple stmt, edge *taken_edge_p) ...@@ -5658,7 +5681,7 @@ vrp_visit_cond_stmt (gimple stmt, edge *taken_edge_p)
val = vrp_evaluate_conditional_warnv_with_ops (gimple_cond_code (stmt), val = vrp_evaluate_conditional_warnv_with_ops (gimple_cond_code (stmt),
gimple_cond_lhs (stmt), gimple_cond_lhs (stmt),
gimple_cond_rhs (stmt), gimple_cond_rhs (stmt),
false, &sop); false, &sop, NULL);
if (val) if (val)
{ {
if (!sop) if (!sop)
......
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