Commit 77a30264 by Richard Guenther Committed by Richard Biener

tree-vrp.c (extract_range_from_binary_expr): Handle overflow from unsigned additions.

2009-04-24  Richard Guenther  <rguenther@suse.de>

	* tree-vrp.c (extract_range_from_binary_expr): Handle overflow
	from unsigned additions.

	* gcc.dg/tree-ssa/vrp48.c: New testcase.

From-SVN: r146742
parent 2b6da65c
2009-04-24 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (extract_range_from_binary_expr): Handle overflow
from unsigned additions.
2009-04-24 Joseph Myers <joseph@codesourcery.com>
* c-typeck.c (set_init_index): Allow array designators that are
......
2009-04-24 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/vrp48.c: New testcase.
2009-04-24 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/array-const-1.c, gcc.dg/array-const-2.c,
......
extern void link_failure (void);
static int __attribute__ ((noinline)) foo (int x)
{
if (x >= 1)
if (x <= 10)
{
if (x < 1 || x > 10)
link_failure ();
x = x + 1;
}
return x;
}
int main (void)
{
int i = foo (0);
return 0;
}
......@@ -2248,6 +2248,22 @@ extract_range_from_binary_expr (value_range_t *vr,
the same end of each range. */
min = vrp_int_const_binop (code, vr0.min, vr1.min);
max = vrp_int_const_binop (code, vr0.max, vr1.max);
/* If both additions overflowed the range kind is still correct.
This happens regularly with subtracting something in unsigned
arithmetic.
??? See PR30318 for all the cases we do not handle. */
if (code == PLUS_EXPR
&& (TREE_OVERFLOW (min) && !is_overflow_infinity (min))
&& (TREE_OVERFLOW (max) && !is_overflow_infinity (max)))
{
min = build_int_cst_wide (TREE_TYPE (min),
TREE_INT_CST_LOW (min),
TREE_INT_CST_HIGH (min));
max = build_int_cst_wide (TREE_TYPE (max),
TREE_INT_CST_LOW (max),
TREE_INT_CST_HIGH (max));
}
}
else if (code == MULT_EXPR
|| code == TRUNC_DIV_EXPR
......
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