* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167955
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
+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
--- /dev/null
+// 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 ();
+}
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. */