re PR tree-optimization/33615 (Hoisting of potentially-throwing values for -fnon...
authorRichard Sandiford <rsandifo@nildram.co.uk>
Tue, 9 Oct 2007 11:05:33 +0000 (11:05 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 9 Oct 2007 11:05:33 +0000 (11:05 +0000)
gcc/
PR tree-optimization/33615
* tree-ssa-pre.c (compute_avail): Don't call make_values_for_stmt
if the statement might throw.  Fix formatting.

gcc/testsuite/
PR tree-optimization/33615
* g++.dg/tree-ssa/pr33615-2.C: New test.

From-SVN: r129164

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C [new file with mode: 0644]
gcc/tree-ssa-pre.c

index 1d66ea3..43c2c9d 100644 (file)
@@ -1,6 +1,12 @@
 2007-10-09  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        PR tree-optimization/33615
+       * tree-ssa-pre.c (compute_avail): Don't call make_values_for_stmt
+       if the statement might throw.  Fix formatting.
+
+2007-10-09  Richard Sandiford  <rsandifo@nildram.co.uk>
+
+       PR tree-optimization/33615
        * tree-ssa-loop-im.c (movement_possibility): Return MOVE_IMPOSSIBLE
        if the rhs might throw.
 
index f6665d5..61dd6de 100644 (file)
@@ -1,6 +1,11 @@
 2007-10-09  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        PR tree-optimization/33615
+       * g++.dg/tree-ssa/pr33615-2.C: New test.
+
+2007-10-09  Richard Sandiford  <rsandifo@nildram.co.uk>
+
+       PR tree-optimization/33615
        * g++.dg/tree-ssa/pr33615.C: New test.
 
 2007-10-08  Alexandre Oliva  <aoliva@redhat.com>
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr33615-2.C
new file mode 100644 (file)
index 0000000..542731a
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fnon-call-exceptions -fdump-tree-pre-details -w" } */
+
+extern volatile int y;
+
+double
+foo (double a, int x)
+{
+  while (x--)
+    {
+      y++;
+      a += 1.0 / 0.0;
+    }
+  return a;
+}
+
+// The expression 1.0 / 0.0 should not be treated as a loop invariant
+// if it may throw an exception.
+// { dg-final { scan-tree-dump-times "Replaced 1\\\.0e\\\+0 / 0\\\.0" 0 "pre" } }
+// { dg-final { cleanup-tree-dump "pre" } }
index 33c44ee..6203467 100644 (file)
@@ -3555,10 +3555,11 @@ compute_avail (void)
            }
 
          else if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
-             && !ann->has_volatile_ops
-             && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) == SSA_NAME
-             && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI
-                  (GIMPLE_STMT_OPERAND (stmt, 0)))
+                  && !ann->has_volatile_ops
+                  && TREE_CODE (GIMPLE_STMT_OPERAND (stmt, 0)) == SSA_NAME
+                  && (!SSA_NAME_OCCURS_IN_ABNORMAL_PHI
+                      (GIMPLE_STMT_OPERAND (stmt, 0)))
+                  && !tree_could_throw_p (stmt))
            {
              if (make_values_for_stmt (stmt, block))
                continue;