]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/43213 (Worse code generated with -O2)
authorRichard Guenther <rguenther@suse.de>
Mon, 1 Mar 2010 12:56:44 +0000 (12:56 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 1 Mar 2010 12:56:44 +0000 (12:56 +0000)
2010-03-01  Richard Guenther  <rguenther@suse.de>

PR middle-end/43213
* expr.c (expand_assignment): Use the alias-oracle to tell
if the rhs aliases the result decl.

* gcc.dg/pr43213.c: New testcase.

From-SVN: r157142

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr43213.c [new file with mode: 0644]

index 26c50318a562eddd325beb54080cb1b1d202b34a..8ea24d342776b789b72d2970bb409a0e9fc7bd1a 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-01  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/43213
+       * expr.c (expand_assignment): Use the alias-oracle to tell
+       if the rhs aliases the result decl.
+
 2010-03-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR pch/14940
index cd013b023a682107dca5a6819cc6cbd4f0c839f9..1e74f2a6911ec24bf57a54a675405a00a2135ba6 100644 (file)
@@ -4432,9 +4432,11 @@ expand_assignment (tree to, tree from, bool nontemporal)
   /* In case we are returning the contents of an object which overlaps
      the place the value is being stored, use a safe function when copying
      a value through a pointer into a structure value return block.  */
-  if (TREE_CODE (to) == RESULT_DECL && TREE_CODE (from) == INDIRECT_REF
+  if (TREE_CODE (to) == RESULT_DECL
+      && TREE_CODE (from) == INDIRECT_REF
       && ADDR_SPACE_GENERIC_P
-         (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (from, 0)))))
+          (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (from, 0)))))
+      && refs_may_alias_p (to, from)
       && cfun->returns_struct
       && !cfun->returns_pcc_struct)
     {
index c399e8030c7e20e2e3c5e6c7c080ade5d21799bb..fcdfdf7dc0b9ad008198bf7ad75b6b310147070b 100644 (file)
@@ -1,3 +1,8 @@
+2010-03-01  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/43213
+       * gcc.dg/pr43213.c: New testcase.
+
 2010-03-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * lib/target-supports.exp (check_effective_target_ucn_nocache):
diff --git a/gcc/testsuite/gcc.dg/pr43213.c b/gcc/testsuite/gcc.dg/pr43213.c
new file mode 100644 (file)
index 0000000..d12fb22
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+struct S {
+  int i;
+};
+
+struct S f(int i)
+{
+  return *(struct S *)&i;
+}
+
+/* { dg-final { scan-assembler-not "memmove" } } */
This page took 0.077321 seconds and 5 git commands to generate.