]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/26135 (store copyprop not effective)
authorRichard Biener <rguenth@gcc.gnu.org>
Fri, 7 Apr 2006 08:04:26 +0000 (08:04 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 7 Apr 2006 08:04:26 +0000 (08:04 +0000)
2006-04-07  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/26135
* tree-ssa-copy.c (stmt_may_generate_copy): Handle memory
loads for store copy-prop.
(copy_prop_visit_stmt): Likewise.

* gcc.dg/tree-ssa/ssa-copyprop-1.c: New testcase.

From-SVN: r112749

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-copyprop-1.c [new file with mode: 0644]
gcc/tree-ssa-copy.c

index f15b03e98bd1d830f8073c4387fc0ebf25020e7c..505f08430e8d8e6a93d05561dd9ab21c36327f73 100644 (file)
@@ -1,4 +1,11 @@
-2006-03-05  Robert Millan  <robertmh@gnu.org>
+2006-04-07  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/26135
+       * tree-ssa-copy.c (stmt_may_generate_copy): Handle memory
+       loads for store copy-prop.
+       (copy_prop_visit_stmt): Likewise.
+
+2006-04-05  Robert Millan  <robertmh@gnu.org>
 
        * gcc/config/i386/linux.h:  Add a comment to mark macros that are
        being overriden in config/k*bsd-gnu.h.
index 41398327f3d6dbecdc1c0405b1d4fdc04f11c14f..b1543eaa02ae0420a8dc9f598f502167a6bfa46f 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-07  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/26135
+       * gcc.dg/tree-ssa/ssa-copyprop-1.c: New testcase.
+
 2006-04-06  Jan Hubicka  <jh@suse.cz>
 
        PR profile/26399
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-copyprop-1.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-copyprop-1.c
new file mode 100644 (file)
index 0000000..4308cea
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-store_copyprop-details" } */
+
+typedef struct { int i; int j; } A;
+int foo(A *a, int i)
+{
+  a->i = i;
+  return a->i;
+}
+
+/* { dg-final { scan-tree-dump "return i" "store_copyprop" } } */
+/* { dg-final { cleanup-tree-dump "store_copyprop" } } */
index d3bc53364fdce805d9c3c18ba8b8e5f93f76d303..fca44d76c05572b4189b73797632fe8394647acb 100644 (file)
@@ -376,7 +376,10 @@ stmt_may_generate_copy (tree stmt)
   /* Otherwise, the only statements that generate useful copies are
      assignments whose RHS is just an SSA name that doesn't flow
      through abnormal edges.  */
-  return TREE_CODE (rhs) == SSA_NAME && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs);
+  return (do_store_copy_prop
+         && TREE_CODE (lhs) == SSA_NAME)
+        || (TREE_CODE (rhs) == SSA_NAME
+            && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs));
 }
 
 
@@ -681,6 +684,34 @@ copy_prop_visit_stmt (tree stmt, edge *taken_edge_p, tree *result_p)
         see if the lattice value of its output has changed.  */
       retval = copy_prop_visit_assignment (stmt, result_p);
     }
+  else if (TREE_CODE (stmt) == MODIFY_EXPR
+          && TREE_CODE (TREE_OPERAND (stmt, 0)) == SSA_NAME
+          && do_store_copy_prop
+          && stmt_makes_single_load (stmt))
+    {
+      /* If the statement is a copy assignment with a memory load
+        on the RHS, see if we know the value of this load and
+        update the lattice accordingly.  */
+      prop_value_t *val = get_value_loaded_by (stmt, copy_of);
+      if (val
+         && val->mem_ref
+         && is_gimple_reg (val->value)
+         && operand_equal_p (val->mem_ref, TREE_OPERAND (stmt, 1), 0))
+        {
+         bool changed;
+         changed = set_copy_of_val (TREE_OPERAND (stmt, 0),
+                                    val->value, val->mem_ref);
+         if (changed)
+           {
+             *result_p = TREE_OPERAND (stmt, 0);
+             retval = SSA_PROP_INTERESTING;
+           }
+         else
+           retval = SSA_PROP_NOT_INTERESTING;
+       }
+      else
+        retval = SSA_PROP_VARYING;
+    }
   else if (TREE_CODE (stmt) == COND_EXPR)
     {
       /* See if we can determine which edge goes out of a conditional