tree-vrp.c (compare_values_warnv): Check TREE_NO_WARNING on a PLUS_EXPR or MINUS_EXPR node before setting...

./:	* tree-vrp.c (compare_values_warnv): Check TREE_NO_WARNING on a
	PLUS_EXPR or MINUS_EXPR node before setting *strict_overflow_p.
	(extract_range_from_assert): Set TREE_NO_WARNING when creating an
	expression.
	(test_for_singularity): Likewise.
testsuite/:
	* gcc.dg/Wstrict-overflow-19.c: New test.

From-SVN: r125334
This commit is contained in:
Ian Lance Taylor 2007-06-05 13:18:22 +00:00 committed by Ian Lance Taylor
parent a176d60f9d
commit 3fe5bcaf11
4 changed files with 38 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2007-06-05 Ian Lance Taylor <iant@google.com>
* tree-vrp.c (compare_values_warnv): Check TREE_NO_WARNING on a
PLUS_EXPR or MINUS_EXPR node before setting *strict_overflow_p.
(extract_range_from_assert): Set TREE_NO_WARNING when creating an
expression.
(test_for_singularity): Likewise.
2007-06-05 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/constraints.md ("Y2"): Replaced by ...

View File

@ -1,3 +1,7 @@
2007-06-05 Ian Lance Taylor <iant@google.com>
* gcc.dg/Wstrict-overflow-19.c: New test.
2007-06-05 Razya Ladelsky <razya@il.ibm.com>
* gcc.dg/matrix/matrix-6.c: Remove conversion.

View File

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
/* Don't warn about an overflow when threading jumps. We used to get
a warning from comparing bounds generated by VRP. */
int
bar(int a, int b, int n)
{
if (b > a)
n = a - b;
if (a >= b)
n = 1;
return n;
}

View File

@ -837,7 +837,9 @@ compare_values_warnv (tree val1, tree val2, bool *strict_overflow_p)
if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (val1)))
return -2;
if (strict_overflow_p != NULL)
if (strict_overflow_p != NULL
&& (code1 == SSA_NAME || !TREE_NO_WARNING (val1))
&& (code2 == SSA_NAME || !TREE_NO_WARNING (val2)))
*strict_overflow_p = true;
if (code1 == SSA_NAME)
@ -1252,6 +1254,8 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
{
tree one = build_int_cst (type, 1);
max = fold_build2 (MINUS_EXPR, type, max, one);
if (EXPR_P (max))
TREE_NO_WARNING (max) = 1;
}
set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv);
@ -1285,6 +1289,8 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
{
tree one = build_int_cst (type, 1);
min = fold_build2 (PLUS_EXPR, type, min, one);
if (EXPR_P (min))
TREE_NO_WARNING (min) = 1;
}
set_value_range (vr_p, VR_RANGE, min, max, vr_p->equiv);
@ -5646,6 +5652,8 @@ test_for_singularity (enum tree_code cond_code, tree op0,
{
tree one = build_int_cst (TREE_TYPE (op0), 1);
max = fold_build2 (MINUS_EXPR, TREE_TYPE (op0), max, one);
if (EXPR_P (max))
TREE_NO_WARNING (max) = 1;
}
}
else if (cond_code == GE_EXPR || cond_code == GT_EXPR)
@ -5659,6 +5667,8 @@ test_for_singularity (enum tree_code cond_code, tree op0,
{
tree one = build_int_cst (TREE_TYPE (op0), 1);
min = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), min, one);
if (EXPR_P (min))
TREE_NO_WARNING (min) = 1;
}
}