re PR tree-optimization/43655 (-ftree-ter causes FAIL: g++.old-deja/g++.law/temps5...
authorJakub Jelinek <jakub@redhat.com>
Thu, 16 Dec 2010 21:44:02 +0000 (22:44 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 16 Dec 2010 21:44:02 +0000 (22:44 +0100)
PR tree-optimization/43655
* tree-ssa-ter.c (is_replaceable_p): Don't use
gimple_references_memory_p for -O0, instead check for load
by looking at rhs.

* g++.dg/opt/pr43655.C: New test.

From-SVN: r167955

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr43655.C [new file with mode: 0644]
gcc/tree-ssa-ter.c

index 287d21efaa9bd3a019b29dcc53ff3caef03d09cf..de5aae5272dbe03a1b2ba090e54c9d14b90d03fd 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/43655
+       * tree-ssa-ter.c (is_replaceable_p): Don't use
+       gimple_references_memory_p for -O0, instead check for load
+       by looking at rhs.
+
 2010-12-16  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR tree-optimization/46404
index 8cfb516a2abf81df5e136db9ce9bcbc5c0c2496c..b5c1508e5d76ca1f7e8f60d10f317c85eeee3059 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/43655
+       * g++.dg/opt/pr43655.C: New test.
+
 2010-12-16  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR tree-optimization/46404
diff --git a/gcc/testsuite/g++.dg/opt/pr43655.C b/gcc/testsuite/g++.dg/opt/pr43655.C
new file mode 100644 (file)
index 0000000..f7e370b
--- /dev/null
@@ -0,0 +1,34 @@
+// PR tree-optimization/43655
+// { dg-do run }
+// { dg-options "-O0 -ftree-ter" }
+
+extern "C" void abort ();
+
+struct C
+{
+  C (int i) : val(i) { }
+  C (const C& c) : val(c.val) { }
+  ~C (void) { val = 999; }
+  C& operator = (const C& c) { val = c.val; return *this; }
+  C& inc (int i) { val += i; return *this; }
+  int val;
+};
+
+C
+f ()
+{
+  return C (3);
+}
+
+C
+f (int i)
+{
+  return f ().inc (i);
+}
+
+int
+main ()
+{
+  if (f (2).val != 5)
+    abort ();
+}
index 7bd766954fa2c8ffa32f3b4b1cb80eabe8f10013..47954cfa3488b4cd7425c5b7981d4d7439525400 100644 (file)
@@ -416,7 +416,9 @@ is_replaceable_p (gimple stmt)
     return false;
 
   /* Without alias info we can't move around loads.  */
-  if (gimple_references_memory_p (stmt) && !optimize)
+  if (!optimize
+      && gimple_assign_single_p (stmt)
+      && !is_gimple_val (gimple_assign_rhs1 (stmt)))
     return false;
 
   /* Float expressions must go through memory if float-store is on.  */