aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C42
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C41
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C28
-rw-r--r--gcc/tree-ssa-pre.c7
5 files changed, 123 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 88c5974..38edb12 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
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
index 0000000..d3c053e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr24231-1.C
@@ -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
index 0000000..188b1a2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr24231-2.C
@@ -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
index 0000000..a9ea58b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr24231-3.C
@@ -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();
+}
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index b0e7953..425d220 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -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);
- 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))
{
+
/* 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;
}
}
- 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)