diff options
author | Richard Guenther <rguenther@suse.de> | 2009-06-29 11:57:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2009-06-29 11:57:15 +0000 |
commit | 09a782ebdacc6a5227ed464d47eb3cc27e252c6a (patch) | |
tree | 50e923e8964fbc46128696b82c92d91fa0a41a33 | |
parent | 152413f7edcf11d34026246569f5145d414f1653 (diff) | |
download | gcc-09a782ebdacc6a5227ed464d47eb3cc27e252c6a.zip gcc-09a782ebdacc6a5227ed464d47eb3cc27e252c6a.tar.gz gcc-09a782ebdacc6a5227ed464d47eb3cc27e252c6a.tar.bz2 |
re PR tree-optimization/40579 (gcc -O2 optimization causes infinite loop and wrong output)
2009-06-29 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40579
* tree-vrp.c (vrp_evaluate_conditional): Bail out early if
the IL to simplify has constants that overflowed.
* gcc.c-torture/execute/pr40579.c: New testcase.
From-SVN: r149046
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr40579.c | 28 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 8 |
4 files changed, 47 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e6a5cea..13aeba0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-06-29 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/40579 + * tree-vrp.c (vrp_evaluate_conditional): Bail out early if + the IL to simplify has constants that overflowed. + 2009-06-28 Uros Bizjak <ubizjak@gmail.com> PR tree-optimization/40550 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80fe78b..b819b37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-06-29 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/40579 + * gcc.c-torture/execute/pr40579.c: New testcase. + 2009-06-28 Uros Bizjak <ubizjak@gmail.com> PR tree-optimization/40550 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr40579.c b/gcc/testsuite/gcc.c-torture/execute/pr40579.c new file mode 100644 index 0000000..7f44af3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr40579.c @@ -0,0 +1,28 @@ +extern void abort (void); +static char * __attribute__((noinline)) +itos(int num) +{ + return (char *)0; +} +static void __attribute__((noinline)) +foo(int i, const char *x) +{ + if (i >= 4) + abort (); +} +int main() +{ + int x = -__INT_MAX__ + 3; + int i; + + for (i = 0; i < 4; ++i) + { + char *p; + --x; + p = itos(x); + foo(i, p); + } + + return 0; +} + diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 41a1beb..13ed4c0 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5679,6 +5679,14 @@ vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, gimple stmt) tree ret; bool only_ranges; + /* Some passes and foldings leak constants with overflow flag set + into the IL. Avoid doing wrong things with these and bail out. */ + if ((TREE_CODE (op0) == INTEGER_CST + && TREE_OVERFLOW (op0)) + || (TREE_CODE (op1) == INTEGER_CST + && TREE_OVERFLOW (op1))) + return NULL_TREE; + sop = false; ret = vrp_evaluate_conditional_warnv_with_ops (code, op0, op1, true, &sop, &only_ranges); |