re PR tree-optimization/33565 (spurious warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true)
./: PR tree-optimization/33565 * tree-ssa-loop-ch.c (copy_loop_headers): Set TREE_NO_WARNING on assignments of comparisons. * tree-ssa-sccvn.c (simplify_binary_expression): Add stmt parameter. Change caller. Defer overflow warnings around call to fold_binary. * fold-const.c (fold_undefer_overflow_warnings): Don't warn if TREE_NO_WARNING is set on the statement. * tree-ssa-forwprop.c (tree_ssa_forward_propagate_single_use_vars): Don't test TREE_NO_WARNING when calling fold_undefer_overflow_warnings. * tree-cfg.c (fold_cond_expr_cond): Likewise. testsuite/: PR tree-optimization/33565 * gcc.dg/Wstrict-overflow-20.c: New test. From-SVN: r128840
This commit is contained in:
parent
c304878307
commit
e233ac979c
8 changed files with 60 additions and 10 deletions
|
@ -1,3 +1,18 @@
|
|||
2007-09-27 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
PR tree-optimization/33565
|
||||
* tree-ssa-loop-ch.c (copy_loop_headers): Set TREE_NO_WARNING on
|
||||
assignments of comparisons.
|
||||
* tree-ssa-sccvn.c (simplify_binary_expression): Add stmt
|
||||
parameter. Change caller. Defer overflow warnings around call to
|
||||
fold_binary.
|
||||
* fold-const.c (fold_undefer_overflow_warnings): Don't warn if
|
||||
TREE_NO_WARNING is set on the statement.
|
||||
* tree-ssa-forwprop.c
|
||||
(tree_ssa_forward_propagate_single_use_vars): Don't test
|
||||
TREE_NO_WARNING when calling fold_undefer_overflow_warnings.
|
||||
* tree-cfg.c (fold_cond_expr_cond): Likewise.
|
||||
|
||||
2007-09-27 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* config/rs6000/rs6000.c (rs6000_legitimize_address): Do not
|
||||
|
|
|
@ -974,6 +974,9 @@ fold_undefer_overflow_warnings (bool issue, const_tree stmt, int code)
|
|||
if (!issue || warnmsg == NULL)
|
||||
return;
|
||||
|
||||
if (stmt != NULL_TREE && TREE_NO_WARNING (stmt))
|
||||
return;
|
||||
|
||||
/* Use the smallest code level when deciding to issue the
|
||||
warning. */
|
||||
if (code == 0 || code > (int) fold_deferred_overflow_code)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2007-09-27 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
PR tree-optimization/33565
|
||||
* gcc.dg/Wstrict-overflow-20.c: New test.
|
||||
|
||||
2007-09-27 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
|
||||
* gfortran.dg/openmp_stack.f90: Fix typo.
|
||||
|
|
13
gcc/testsuite/gcc.dg/Wstrict-overflow-20.c
Normal file
13
gcc/testsuite/gcc.dg/Wstrict-overflow-20.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
|
||||
|
||||
/* Don't warn about an overflow in a copied loop header. We used to
|
||||
get a warning in value numbering. This is PR 33565. */
|
||||
|
||||
void f (int m, int n)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = m; j < m + 10 && j < n; j ++)
|
||||
do_something (j);
|
||||
}
|
|
@ -417,8 +417,7 @@ fold_cond_expr_cond (void)
|
|||
cond = fold (COND_EXPR_COND (stmt));
|
||||
zerop = integer_zerop (cond);
|
||||
onep = integer_onep (cond);
|
||||
fold_undefer_overflow_warnings (((zerop || onep)
|
||||
&& !TREE_NO_WARNING (stmt)),
|
||||
fold_undefer_overflow_warnings (zerop || onep,
|
||||
stmt,
|
||||
WARN_STRICT_OVERFLOW_CONDITIONAL);
|
||||
if (zerop)
|
||||
|
|
|
@ -1021,8 +1021,7 @@ tree_ssa_forward_propagate_single_use_vars (void)
|
|||
did_something = forward_propagate_into_cond (stmt, stmt);
|
||||
if (did_something == 2)
|
||||
cfg_changed = true;
|
||||
fold_undefer_overflow_warnings (!TREE_NO_WARNING (stmt)
|
||||
&& did_something, stmt,
|
||||
fold_undefer_overflow_warnings (did_something, stmt,
|
||||
WARN_STRICT_OVERFLOW_CONDITIONAL);
|
||||
bsi_next (&bsi);
|
||||
}
|
||||
|
|
|
@ -215,11 +215,22 @@ copy_loop_headers (void)
|
|||
|
||||
for (i = 0; i < n_bbs; ++i)
|
||||
{
|
||||
tree last;
|
||||
block_stmt_iterator bsi;
|
||||
|
||||
last = last_stmt (copied_bbs[i]);
|
||||
if (TREE_CODE (last) == COND_EXPR)
|
||||
TREE_NO_WARNING (last) = 1;
|
||||
for (bsi = bsi_start (copied_bbs[i]);
|
||||
!bsi_end_p (bsi);
|
||||
bsi_next (&bsi))
|
||||
{
|
||||
tree stmt = bsi_stmt (bsi);
|
||||
if (TREE_CODE (stmt) == COND_EXPR)
|
||||
TREE_NO_WARNING (stmt) = 1;
|
||||
else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT)
|
||||
{
|
||||
tree rhs = GIMPLE_STMT_OPERAND (stmt, 1);
|
||||
if (COMPARISON_CLASS_P (rhs))
|
||||
TREE_NO_WARNING (stmt) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1390,7 +1390,7 @@ valueize_expr (tree expr)
|
|||
simplified. */
|
||||
|
||||
static tree
|
||||
simplify_binary_expression (tree rhs)
|
||||
simplify_binary_expression (tree stmt, tree rhs)
|
||||
{
|
||||
tree result = NULL_TREE;
|
||||
tree op0 = TREE_OPERAND (rhs, 0);
|
||||
|
@ -1421,8 +1421,13 @@ simplify_binary_expression (tree rhs)
|
|||
&& op1 == TREE_OPERAND (rhs, 1))
|
||||
return NULL_TREE;
|
||||
|
||||
fold_defer_overflow_warnings ();
|
||||
|
||||
result = fold_binary (TREE_CODE (rhs), TREE_TYPE (rhs), op0, op1);
|
||||
|
||||
fold_undefer_overflow_warnings (result && valid_gimple_expression_p (result),
|
||||
stmt, 0);
|
||||
|
||||
/* Make sure result is not a complex expression consisting
|
||||
of operators of operators (IE (a + b) + (a + c))
|
||||
Otherwise, we will end up with unbounded expressions if
|
||||
|
@ -1522,7 +1527,7 @@ try_to_simplify (tree stmt, tree rhs)
|
|||
break;
|
||||
case tcc_comparison:
|
||||
case tcc_binary:
|
||||
return simplify_binary_expression (rhs);
|
||||
return simplify_binary_expression (stmt, rhs);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue