Commit d7419dec by Ian Lance Taylor Committed by Ian Lance Taylor

tree-vrp.c (vrp_int_const_binop): Handle PLUS_EXPR and the *_DIV_EXPR codes…

tree-vrp.c (vrp_int_const_binop): Handle PLUS_EXPR and the *_DIV_EXPR codes correctly with overflow infinities.

	* tree-vrp.c (vrp_int_const_binop): Handle PLUS_EXPR and
	the *_DIV_EXPR codes correctly with overflow infinities.

From-SVN: r122820
parent bd91a8c4
2007-03-11 Ian Lance Taylor <iant@google.com>
* tree-vrp.c (vrp_int_const_binop): Handle PLUS_EXPR and
the *_DIV_EXPR codes correctly with overflow infinities.
2007-03-11 Ira Rosen <irar@il.ibm.com> 2007-03-11 Ira Rosen <irar@il.ibm.com>
* tree-data-ref.c (analyze_offset): Add a return value (bool) to * tree-data-ref.c (analyze_offset): Add a return value (bool) to
......
...@@ -1519,15 +1519,26 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2) ...@@ -1519,15 +1519,26 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
&& !supports_overflow_infinity (TREE_TYPE (res))) && !supports_overflow_infinity (TREE_TYPE (res)))
return NULL_TREE; return NULL_TREE;
/* We have to punt on subtracting infinities of the same sign, /* We have to punt on adding infinities of different signs,
since we can't tell what the sign of the result should since we can't tell what the sign of the result should be.
be. */ Likewise for subtracting infinities of the same sign. */
if (code == MINUS_EXPR if (((code == PLUS_EXPR && sgn1 != sgn2)
&& sgn1 == sgn2 || (code == MINUS_EXPR && sgn1 == sgn2))
&& is_overflow_infinity (val1) && is_overflow_infinity (val1)
&& is_overflow_infinity (val2)) && is_overflow_infinity (val2))
return NULL_TREE; return NULL_TREE;
/* Don't try to handle division or shifting of infinities. */
if ((code == TRUNC_DIV_EXPR
|| code == FLOOR_DIV_EXPR
|| code == CEIL_DIV_EXPR
|| code == EXACT_DIV_EXPR
|| code == ROUND_DIV_EXPR
|| code == RSHIFT_EXPR)
&& (is_overflow_infinity (val1)
|| is_overflow_infinity (val2)))
return NULL_TREE;
/* Notice that we only need to handle the restricted set of /* Notice that we only need to handle the restricted set of
operations handled by extract_range_from_binary_expr. operations handled by extract_range_from_binary_expr.
Among them, only multiplication, addition and subtraction Among them, only multiplication, addition and subtraction
...@@ -1541,8 +1552,12 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2) ...@@ -1541,8 +1552,12 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
if ((code == MULT_EXPR && sgn1 == sgn2) if ((code == MULT_EXPR && sgn1 == sgn2)
/* For addition, the operands must be of the same sign /* For addition, the operands must be of the same sign
to yield an overflow. Its sign is therefore that to yield an overflow. Its sign is therefore that
of one of the operands, for example the first. */ of one of the operands, for example the first. For
|| (code == PLUS_EXPR && sgn1 > 0) infinite operands X + -INF is negative, not positive. */
|| (code == PLUS_EXPR
&& (sgn1 >= 0
? !is_negative_overflow_infinity (val2)
: is_positive_overflow_infinity (val2)))
/* For subtraction, non-infinite operands must be of /* For subtraction, non-infinite operands must be of
different signs to yield an overflow. Its sign is different signs to yield an overflow. Its sign is
therefore that of the first operand or the opposite of therefore that of the first operand or the opposite of
......
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