Commit 09b2f9e8 by Roger Sayle Committed by Roger Sayle

fold-const.c (swap_tree_comparison): Add support for unordered floating point comparisons.


	* fold-const.c (swap_tree_comparison): Add support for unordered
	floating point comparisons.
	* tree-vrp.c (opposite_comparison): Delete.
	(extract_range_from_assert): Replace calls to opposite_comparison
	with calls to swap_tree_comparison.
	(register_edge_assert_for): Likewise.
	(vrp_evaluate_conditional): Likewise.

From-SVN: r101201
parent 115766b6
2005-06-19 Roger Sayle <roger@eyesopen.com>
* fold-const.c (swap_tree_comparison): Add support for unordered
floating point comparisons.
* tree-vrp.c (opposite_comparison): Delete.
(extract_range_from_assert): Replace calls to opposite_comparison
with calls to swap_tree_comparison.
(register_edge_assert_for): Likewise.
(vrp_evaluate_conditional): Likewise.
2005-06-20 Kaz Kojima <kkojima@gcc.gnu.org> 2005-06-20 Kaz Kojima <kkojima@gcc.gnu.org>
* integrate.c (allocate_initial_values): Update the references * integrate.c (allocate_initial_values): Update the references
......
...@@ -2169,6 +2169,10 @@ swap_tree_comparison (enum tree_code code) ...@@ -2169,6 +2169,10 @@ swap_tree_comparison (enum tree_code code)
{ {
case EQ_EXPR: case EQ_EXPR:
case NE_EXPR: case NE_EXPR:
case ORDERED_EXPR:
case UNORDERED_EXPR:
case LTGT_EXPR:
case UNEQ_EXPR:
return code; return code;
case GT_EXPR: case GT_EXPR:
return LT_EXPR; return LT_EXPR;
...@@ -2178,6 +2182,14 @@ swap_tree_comparison (enum tree_code code) ...@@ -2178,6 +2182,14 @@ swap_tree_comparison (enum tree_code code)
return GT_EXPR; return GT_EXPR;
case LE_EXPR: case LE_EXPR:
return GE_EXPR; return GE_EXPR;
case UNGT_EXPR:
return UNLT_EXPR;
case UNGE_EXPR:
return UNLE_EXPR;
case UNLT_EXPR:
return UNGT_EXPR;
case UNLE_EXPR:
return UNGE_EXPR;
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
......
...@@ -94,46 +94,6 @@ static sbitmap blocks_visited; ...@@ -94,46 +94,6 @@ static sbitmap blocks_visited;
of values that SSA name N_I may take. */ of values that SSA name N_I may take. */
static value_range_t **vr_value; static value_range_t **vr_value;
/* Given a comparison code, return its opposite. Note that this is *not*
the same as inverting its truth value (invert_tree_comparison). Here we
just want to literally flip the comparison around.
So, '<' gets '>', '<=' gets '>='. Both '==' and '!=' are returned
unchanged. */
static enum tree_code
opposite_comparison (enum tree_code code)
{
switch (code)
{
case EQ_EXPR:
case NE_EXPR:
case ORDERED_EXPR:
case UNORDERED_EXPR:
case LTGT_EXPR:
case UNEQ_EXPR:
return code;
case GT_EXPR:
return LT_EXPR;
case GE_EXPR:
return LE_EXPR;
case LT_EXPR:
return GT_EXPR;
case LE_EXPR:
return GE_EXPR;
case UNGT_EXPR:
return UNLT_EXPR;
case UNGE_EXPR:
return UNLE_EXPR;
case UNLT_EXPR:
return UNGT_EXPR;
case UNLE_EXPR:
return UNGE_EXPR;
default:
gcc_unreachable ();
}
}
/* Return true if EXPR computes a non-zero value. */ /* Return true if EXPR computes a non-zero value. */
...@@ -711,7 +671,7 @@ extract_range_from_assert (value_range_t *vr_p, tree expr) ...@@ -711,7 +671,7 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
to flip around the comparison code to create the proper range to flip around the comparison code to create the proper range
for VAR. */ for VAR. */
limit = TREE_OPERAND (cond, 0); limit = TREE_OPERAND (cond, 0);
cond_code = opposite_comparison (TREE_CODE (cond)); cond_code = swap_tree_comparison (TREE_CODE (cond));
} }
type = TREE_TYPE (limit); type = TREE_TYPE (limit);
...@@ -2231,7 +2191,7 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si) ...@@ -2231,7 +2191,7 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si)
/* If the predicate is of the form VAL COMP NAME, flip /* If the predicate is of the form VAL COMP NAME, flip
COMP around because we need to register NAME as the COMP around because we need to register NAME as the
first operand in the predicate. */ first operand in the predicate. */
comp_code = opposite_comparison (TREE_CODE (cond)); comp_code = swap_tree_comparison (TREE_CODE (cond));
val = TREE_OPERAND (cond, 0); val = TREE_OPERAND (cond, 0);
} }
else else
...@@ -3023,7 +2983,7 @@ vrp_evaluate_conditional (tree cond, bool use_equiv_p) ...@@ -3023,7 +2983,7 @@ vrp_evaluate_conditional (tree cond, bool use_equiv_p)
return compare_name_with_value (TREE_CODE (cond), op0, op1); return compare_name_with_value (TREE_CODE (cond), op0, op1);
else if (TREE_CODE (op1) == SSA_NAME) else if (TREE_CODE (op1) == SSA_NAME)
return compare_name_with_value ( return compare_name_with_value (
opposite_comparison (TREE_CODE (cond)), op1, op0); swap_tree_comparison (TREE_CODE (cond)), op1, op0);
} }
else else
{ {
...@@ -3038,7 +2998,7 @@ vrp_evaluate_conditional (tree cond, bool use_equiv_p) ...@@ -3038,7 +2998,7 @@ vrp_evaluate_conditional (tree cond, bool use_equiv_p)
return compare_range_with_value (TREE_CODE (cond), vr0, op1); return compare_range_with_value (TREE_CODE (cond), vr0, op1);
else if (vr0 == NULL && vr1) else if (vr0 == NULL && vr1)
return compare_range_with_value ( return compare_range_with_value (
opposite_comparison (TREE_CODE (cond)), vr1, op0); swap_tree_comparison (TREE_CODE (cond)), vr1, op0);
} }
} }
......
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