From fae25b37f20b5015e494b7314b1d29136b88c5c7 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod <amacleod@redhat.com> Date: Thu, 17 Jan 2008 21:37:14 +0000 Subject: [PATCH] Teach SCCVN that throwing expressions are not to be regenerated. http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00764.html Teach SCCVN that throwing expressions are not to be regenerated. 2008-01-17 Andrew MacLeod <amacleod@redhat.com> * tree-ssa-sccvn.c (visit_use): Expressions which can throw are varying. * gcc.c-torture/compile/pr34648.c: New testcase. From-SVN: r131610 --- gcc/ChangeLog | 5 +++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.c-torture/compile/pr34648.c | 39 +++++++++++++++++++ gcc/tree-ssa-sccvn.c | 3 +- 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr34648.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d00143afc385..91874635b8b3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-01-17 Andrew MacLeod <amacleod@redhat.com> + + PR tree-optimization/34648 + * tree-ssa-sccvn.c (visit_use): Expressions which can throw are varying. + 2008-01-17 Anatoly Sokolov <aesok@post.ru> * config/avr/avr.h (LINK_SPEC): Support -mrelax and -mpmem-wrap-around. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a460685243b..eb8a26cf610f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-17 Andrew MacLeod <amacleod@redhat.com> + + PR tree-optimization/34648 + * gcc.c-torture/compile/pr34648.c: New testcase. + 2008-01-17 Sebastian Pop <sebastian.pop@amd.com> PR testsuite/34821 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34648.c b/gcc/testsuite/gcc.c-torture/compile/pr34648.c new file mode 100644 index 000000000000..1f7472fe76de --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr34648.c @@ -0,0 +1,39 @@ +/* PR tree-optimization/34648 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -fexceptions" } */ + +extern const unsigned short int **bar (void) __attribute__ ((const)); +const char *a; +int b; +char c; + +char +foo (int *x) +{ + char r; + + c = '\0'; + if (!b) + { + while (((*bar ())[a[*x]] & 0x2000) != 0) + (*x)++; + if (a[++(*x)] == '-') + { + (*x)++; + if (a[*x] && !((*bar ())[a[*x]] & 0x2000)) + return '?'; + } + if (!a[*x] || ((*bar ())[a[*x]] & 0x2000)) + { + while (((*bar ())[a[*x]] & 0x2000)) + ++(*x); + return '\0'; + } + } + + r = a[*x]; + b = a[*x] && !((*bar ())[a[*x]] & 0x2000); + return r; +} + diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 7f566dba8e1c..d7b8c8a72d7f 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1609,7 +1609,8 @@ visit_use (tree use) changed = visit_phi (stmt); } else if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT - || (ann && ann->has_volatile_ops)) + || (ann && ann->has_volatile_ops) + || tree_could_throw_p (stmt)) { changed = defs_to_varying (stmt); } -- GitLab