diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-08 17:36:05 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-03-08 17:36:05 +0000 |
commit | a2a1fde2638e7f0ac847a9aaecbbcc522eac2c15 (patch) | |
tree | fa8cc8f84a345de54e6ab532ecec5b191cd7a5ca /gcc/testsuite | |
parent | 4d9301a8521476c8837830fbad62c750e42a11c5 (diff) | |
download | gcc-a2a1fde2638e7f0ac847a9aaecbbcc522eac2c15.tar.gz |
./:
* tree-vrp.c: Include "intl.h".
(usable_range_p): New static function.
(compare_values_warnv): Don't test TYPE_OVERFLOW_UNDEFINED for
overflowed values, juts set *strict_overflow_p.
(compare_values): Only return -2 if one of the operands is not a
constant.
(compare_ranges): Call usable_range_p.
(compare_range_with_value): Likewise.
(vrp_evaluate_conditional_warnv): Rename from
vrp_evaluate_conditional. Make static. Change all callers.
(vrp_evaluate_conditional): New function.
(simplify_div_or_mod_using_ranges): Issue warning about reliance
on signed overflow.
(simplify_abs_using_ranges): Likewise.
(simplify_stmt_for_jump_threading): Add within_stmt parameter.
* tree-ssa-dom.c (simplify_stmt_for_jump_threading): Add
within_stmt parameter.
* tree-ssa-propagate.c (fold_predicate_in): Update call to
vrp_evaluate_conditional.
* tree-ssa-threadedge.c
(record_temporary_equivalences_from_stmts_at_dest): Change
simplify parameter to take a second tree parameter.
(simplify_control_stmt_condition): Likewise.
(thread_across_edge): Likewise.
* tree-flow.h (vrp_evaluate_conditional): Update declaration.
(thread_across_edge): Likewise.
* gcc/Makefile.in (tree-vrp.o): Depend upon intl.h.
testsuite/:
* gcc.dg/no-strict-overflow-5.c: New test.
* gcc.dg/no-strict-overflow-6.c: New test.
* gcc.dg/Wstrict-overflow-11.c: New test.
* gcc.dg/Wstrict-overflow-12.c: New test.
* gcc.dg/Wstrict-overflow-13.c: New test.
* gcc.dg/Wstrict-overflow-14.c: New test.
* gcc.dg/Wstrict-overflow-15.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122706 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-overflow-11.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-overflow-12.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-overflow-13.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-overflow-14.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-overflow-15.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-strict-overflow-5.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/no-strict-overflow-6.c | 21 |
8 files changed, 132 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4de1a123ab9..a2780b4a484 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2007-03-08 Ian Lance Taylor <iant@google.com> + + * gcc.dg/no-strict-overflow-5.c: New test. + * gcc.dg/no-strict-overflow-6.c: New test. + * gcc.dg/Wstrict-overflow-11.c: New test. + * gcc.dg/Wstrict-overflow-12.c: New test. + * gcc.dg/Wstrict-overflow-13.c: New test. + * gcc.dg/Wstrict-overflow-14.c: New test. + * gcc.dg/Wstrict-overflow-15.c: New test. + 2007-03-08 Richard Sandiford <richard@codesourcery.com> * gcc.c-torture/execute/strcmp-1.x: New file. XFAIL execution diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-11.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-11.c new file mode 100644 index 00000000000..c98610e48a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-11.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=1" } */ + +/* Based on strict-overflow-5.c. */ + +/* We can only unroll when using strict overflow semantics. */ + +int foo (int i) +{ + int index; + int r=0; + + for (index = i; index <= i+4; index+=2) /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ + r++; + + return r; +} diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-12.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-12.c new file mode 100644 index 00000000000..177904db74a --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-12.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-6.c. */ + +/* VRP test. This turns into an infinite loop when using strict + overflow semantics. */ + +int +foo () +{ + int i, bits; + for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ + ++bits; + return bits; +} diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-13.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-13.c new file mode 100644 index 00000000000..170d13777fa --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-13.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=2" } */ + +/* Source: Ian Lance Taylor. Dual of no-strict-overflow-6.c. */ + +/* VRP test. This turns into an infinite loop (depending on what + bigtime_test does), but at least we warn about it. */ + +extern int bigtime_test (int); +int +foo () +{ + int j; + for (j = 1; 0 < j; j *= 2) /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ + if (! bigtime_test (j)) + return 1; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c new file mode 100644 index 00000000000..6f3c5a24fd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-14.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=4" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int j) +{ + int i; + int sum = 0; + + for (i = 1; i < j; i += i) + sum += i / 16; /* { dg-warning "assuming signed overflow does not occur" "" } */ + return sum; +} diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c new file mode 100644 index 00000000000..d1627d2f47b --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-15.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow=4" } */ + +/* Source: Ian Lance Taylor. */ + +int +foo (int j) +{ + int i; + int sum = 0; + + for (i = 1; i < j; i += i) + sum += __builtin_abs (i); /* { dg-warning "assuming signed overflow does not occur" "" } */ + return sum; +} diff --git a/gcc/testsuite/gcc.dg/no-strict-overflow-5.c b/gcc/testsuite/gcc.dg/no-strict-overflow-5.c new file mode 100644 index 00000000000..7f82014c76e --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-strict-overflow-5.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-final_cleanup" } */ + +/* Dual of strict-overflow-5.c. */ + +/* We can only unroll when using strict overflow semantics. */ + +int foo (int i) +{ + int index; + int r=0; + + for (index = i; index <= i+4; index+=2) + r++; + + return r; +} + +/* { dg-final { scan-tree-dump-times "r = 3" 0 "final_cleanup" } } */ +/* { dg-final { cleanup-tree-dump "final_cleanup" } } */ diff --git a/gcc/testsuite/gcc.dg/no-strict-overflow-6.c b/gcc/testsuite/gcc.dg/no-strict-overflow-6.c new file mode 100644 index 00000000000..664aa256af5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/no-strict-overflow-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-fno-strict-overflow -O2 -fdump-tree-final_cleanup" } */ + +/* Source: Ian Lance Taylor. */ + +/* VRP test. We can not simplify the conditional when not using + strict overflow semantics. We don't test this with + -fstrict-overflow because it turns into an infinite loop. That is + OK but it would also be OK to not do that. */ + +int +foo () +{ + int i, bits; + for (i = 1, bits = 1; i > 0; i += i) + ++bits; + return bits; +} + +/* { dg-final { scan-tree-dump "return bits" "final_cleanup" } } */ +/* { dg-final { cleanup-tree-dump "final_cleanup" } } */ |