]> gcc.gnu.org Git - gcc.git/commitdiff
tree-ssa-dom.c (record_equality): Use loop depth to determine which way to record...
authorDaniel Berlin <dberlin@dberlin.org>
Sat, 23 Oct 2004 18:00:01 +0000 (18:00 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Sat, 23 Oct 2004 18:00:01 +0000 (18:00 +0000)
2004-10-23  Daniel Berlin  <dberlin@dberlin.org>

* tree-ssa-dom.c (record_equality): Use loop depth to determine
which way to record the equality as well.
(loop_depth_of_name): New function.

From-SVN: r89491

gcc/ChangeLog
gcc/tree-ssa-dom.c

index fa86a45990c8ed19e5199a0bfed99dd7e55f9160..10a63b387639b8478448cd90429a49e444a8f65d 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-23  Daniel Berlin  <dberlin@dberlin.org>
+
+       * tree-ssa-dom.c (record_equality): Use loop depth to determine
+       which way to record the equality as well.
+       (loop_depth_of_name): New function.
+
 2004-10-23  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR middle-end/17793
index c74537ca79bba5afcc288e7284559f6a252e2f11..edd74e03c2e5e5ff7b274f6d2d1e74669ddaed5a 100644 (file)
@@ -1491,6 +1491,35 @@ record_const_or_copy_1 (tree x, tree y, tree prev_x)
   VARRAY_PUSH_TREE (const_and_copies_stack, x);
 }
 
+
+/* Return the loop depth of the basic block of the defining statement of X.
+   This number should not be treated as absolutely correct because the loop
+   information may not be completely up-to-date when dom runs.  However, it
+   will be relatively correct, and as more passes are taught to keep loop info
+   up to date, the result will become more and more accurate.  */
+
+static int
+loop_depth_of_name (tree x)
+{
+  tree defstmt;
+  basic_block defbb;
+
+  /* If it's not an SSA_NAME, we have no clue where the definition is.  */
+  if (TREE_CODE (x) != SSA_NAME)
+    return 0;
+
+  /* Otherwise return the loop depth of the defining statement's bb.
+     Note that there may not actually be a bb for this statement, if the
+     ssa_name is live on entry.  */
+  defstmt = SSA_NAME_DEF_STMT (x);
+  defbb = bb_for_stmt (defstmt);
+  if (!defbb)
+    return 0;
+
+  return defbb->loop_depth;
+}
+
+
 /* Record that X is equal to Y in const_and_copies.  Record undo
    information in the block-local varray.  */
 
@@ -1522,12 +1551,13 @@ record_equality (tree x, tree y)
   if (TREE_CODE (y) == SSA_NAME)
     prev_y = SSA_NAME_VALUE (y);
 
-  /* If one of the previous values is invariant, then use that.
+  /* If one of the previous values is invariant, or invariant in more loops
+     (by depth), then use that.
      Otherwise it doesn't matter which value we choose, just so
      long as we canonicalize on one value.  */
   if (TREE_INVARIANT (y))
     ;
-  else if (TREE_INVARIANT (x))
+  else if (TREE_INVARIANT (x) || (loop_depth_of_name (x) <= loop_depth_of_name (y)))
     prev_x = x, x = y, y = prev_x, prev_x = prev_y;
   else if (prev_x && TREE_INVARIANT (prev_x))
     x = y, y = prev_x, prev_x = prev_y;
This page took 0.081308 seconds and 5 git commands to generate.