diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-27 17:31:34 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-27 17:31:34 +0000 |
commit | 72c59a18cc11b00528f439ea717715b9baddad9d (patch) | |
tree | e09e3c8bc4a42746c82cfe49a69a4098a8e6622b /gcc | |
parent | 06c4be77f669f874fdea3a0576d675cf0fac315a (diff) | |
download | gcc-72c59a18cc11b00528f439ea717715b9baddad9d.tar.gz |
./:
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128840 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/fold-const.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-overflow-20.c | 13 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 3 | ||||
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 3 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-ch.c | 21 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 9 |
8 files changed, 61 insertions, 11 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7a438291bb..78ef879234f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 12413d833d0..62cbfd11ee0 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e7b5252097f..163f80bb999 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-20.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-20.c new file mode 100644 index 00000000000..207162d0e8e --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-20.c @@ -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); +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index fd981f35b0e..320bc8ef61d 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -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) diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index e026b804d40..60e6ffa9e62 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -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); } diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index e895981fa31..ff62c686c28 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -215,11 +215,22 @@ copy_loop_headers (void) for (i = 0; i < n_bbs; ++i) { - tree last; - - last = last_stmt (copied_bbs[i]); - if (TREE_CODE (last) == COND_EXPR) - TREE_NO_WARNING (last) = 1; + block_stmt_iterator bsi; + + 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; + } + } } } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index cddd2d1df58..b4fb014b76d 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -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; |