aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2007-09-30 12:00:36 -0400
committerDiego Novillo <dnovillo@gcc.gnu.org>2007-09-30 12:00:36 -0400
commita45db20b7574c6a50e5b2c3bca189b21973a7b10 (patch)
tree258ac9ccc0b2befc416c750a3f7f91966492098c /gcc
parent80aea554a701f35a6b53fcd9d9fb89d1430fe983 (diff)
downloadgcc-a45db20b7574c6a50e5b2c3bca189b21973a7b10.zip
gcc-a45db20b7574c6a50e5b2c3bca189b21973a7b10.tar.gz
gcc-a45db20b7574c6a50e5b2c3bca189b21973a7b10.tar.bz2
re PR tree-optimization/33593 (tree-outof-ssa moves sources of non-call exceptions past sequence points)
PR 33593 * tree-ssa-ter.c (is_replaceable_p): Return false if STMT may throw an exception. testsuite/ChangeLog PR 33593 * g++.dg/tree-ssa/pr33593.C: New test. From-SVN: r128893
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr33593.C19
-rw-r--r--gcc/tree-ssa-ter.c4
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ea66227..eef9e94 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-30 Diego Novillo <dnovillo@google.com>
+
+ PR 33593
+ * tree-ssa-ter.c (is_replaceable_p): Return false if STMT may
+ throw an exception.
+
2007-09-30 Uros Bizjak <ubizjak@gmail.com>
PR tree-optimization/33597
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 45a3afb..631e8a1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-30 Diego Novillo <dnovillo@google.com>
+
+ PR 33593
+ * g++.dg/tree-ssa/pr33593.C: New test.
+
2007-09-30 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/33400
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr33593.C b/gcc/testsuite/g++.dg/tree-ssa/pr33593.C
new file mode 100644
index 0000000..f549740
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr33593.C
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fnon-call-exceptions -fdump-tree-optimized" } */
+
+#include <stdio.h>
+
+void foo (int) { printf ("Bar\n"); }
+
+int
+main (void)
+{
+ int a = 1 / 0; // { dg-warning "division by zero" }
+ printf ("Foo\n");
+ foo (a);
+}
+
+// The expression 1 / 0 should not be propagated into the call to foo() if it
+// may trap.
+// { dg-final { scan-tree-dump-times "foo \\(1 \\/ 0\\)" 0 "optimized" } }
+// { dg-final { cleanup-tree-dump "optimized" } }
diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c
index 824252e..f0fef24 100644
--- a/gcc/tree-ssa-ter.c
+++ b/gcc/tree-ssa-ter.c
@@ -366,6 +366,10 @@ is_replaceable_p (tree stmt)
if (TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
return false;
+ /* If the statement may throw an exception, it cannot be replaced. */
+ if (tree_could_throw_p (stmt))
+ return false;
+
/* Punt if there is more than 1 def. */
def = SINGLE_SSA_TREE_OPERAND (stmt, SSA_OP_DEF);
if (!def)