OSDN Git Service

2005-10-18 Daniel Berlin <dberlin@dberlin.org>
authordberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Oct 2005 03:34:50 +0000 (03:34 +0000)
committerdberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Oct 2005 03:34:50 +0000 (03:34 +0000)
Fix PR tree-optimization/24231

* tree-ssa-pre.c (try_look_through_load): Skip abnormal phi names
(compute_avail): Ditto.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105594 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 88c5974..38edb12 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-18  Daniel Berlin <dberlin@dberlin.org>
+
+       Fix PR tree-optimization/24231
+
+       * tree-ssa-pre.c (try_look_through_load): Skip abnormal phi names
+       (compute_avail): Ditto.
+
 2006-10-18  Richard Henderson  <rth@redhat.com>
 
        PR target/24428
 2006-10-18  Richard Henderson  <rth@redhat.com>
 
        PR target/24428
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C b/gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C
new file mode 100644 (file)
index 0000000..d3c053e
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* FRE testcase for PR 24231, problem with PRE coalescing abnormal phis.  */
+struct f
+{
+  int i;
+};
+struct h{h();};
+int g(void);
+int g1(void) throw();
+int h2222(f*);
+void ghh(int);
+
+int main(void)
+{
+  int i;
+  f t;
+  try
+  {
+    i = g1();
+    try
+    {
+      i = g();
+    }catch(...)
+    {}
+    int j = i;
+    try
+    { t.i = i;
+      i = g();
+    }catch(...)
+   {}
+    i = 2;
+    int h = t.i;
+    ghh (h);
+
+    g();
+  }catch(...)
+  {}
+  return i;
+}
+
+
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C b/gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C
new file mode 100644 (file)
index 0000000..188b1a2
--- /dev/null
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* FRE testcase for PR 24231, problem with PRE coalescing abnormal phis.  */
+struct f
+{
+  int i;
+};
+struct h{h();};
+int g(void);
+int g1(void) throw();
+int h2222(f*);
+void ghh(int);
+
+int main(void)
+{
+  int i;
+  f t;
+  try
+  {
+    i = g1();
+    try
+    {
+      i = g();
+    }catch(...)
+    {}
+    int j = i;
+    try
+    {
+      i = g();
+    }catch(...)
+    {}
+    t.i = j;
+    i = 2;
+    int h = t.i;
+    ghh (h);
+
+    g();
+  }catch(...)
+  {}
+  return i;
+}
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C b/gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C
new file mode 100644 (file)
index 0000000..a9ea58b
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* PRE testcase for PR 24231, problem with PRE coalescing abnormal phis.  */
+struct MemoryManager {
+      virtual void deallocate() = 0;
+};
+struct XalanVector {
+      ~XalanVector()   {
+             m_memoryManager->deallocate();
+               }
+        void swap(XalanVector& theOther)   {
+               MemoryManager* const theTempManager = m_memoryManager;
+                   m_memoryManager = theOther.m_memoryManager;
+                       theOther.m_memoryManager = theTempManager;
+                           theOther.m_size = 0;
+                             }
+         void push_back()   {
+                 XalanVector theTemp(*this);
+                     theTemp.push_back();
+                         swap(theTemp);
+                           }
+           MemoryManager* m_memoryManager;
+             int m_size;
+};
+void f(void) {
+      XalanVector tempVector;
+        tempVector.push_back();
+}
index b0e7953..425d220 100644 (file)
@@ -2187,11 +2187,13 @@ try_look_through_load (tree lhs, tree mem_ref, tree stmt, basic_block block)
      that all of them come from the same statement STORE_STMT.  See if there
      is a useful expression we can deduce from STORE_STMT.  */
   rhs = TREE_OPERAND (store_stmt, 1);
      that all of them come from the same statement STORE_STMT.  See if there
      is a useful expression we can deduce from STORE_STMT.  */
   rhs = TREE_OPERAND (store_stmt, 1);
-  if (TREE_CODE (rhs) == SSA_NAME
+  if ((TREE_CODE (rhs) == SSA_NAME
+       && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs))
       || is_gimple_min_invariant (rhs)
       || TREE_CODE (rhs) == ADDR_EXPR
       || TREE_INVARIANT (rhs))
     {
       || is_gimple_min_invariant (rhs)
       || TREE_CODE (rhs) == ADDR_EXPR
       || TREE_INVARIANT (rhs))
     {
+      
       /* Yay!  Compute a value number for the RHS of the statement and
         add its value to the AVAIL_OUT set for the block.  Add the LHS
         to TMP_GEN.  */
       /* Yay!  Compute a value number for the RHS of the statement and
         add its value to the AVAIL_OUT set for the block.  Add the LHS
         to TMP_GEN.  */
@@ -2322,7 +2324,8 @@ compute_avail (void)
                      continue;
                    }
                }
                      continue;
                    }
                }
-             else if (TREE_CODE (rhs) == SSA_NAME
+             else if ((TREE_CODE (rhs) == SSA_NAME
+                       && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs))
                       || is_gimple_min_invariant (rhs)
                       || TREE_CODE (rhs) == ADDR_EXPR
                       || TREE_INVARIANT (rhs)
                       || is_gimple_min_invariant (rhs)
                       || TREE_CODE (rhs) == ADDR_EXPR
                       || TREE_INVARIANT (rhs)