aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2004-10-23 18:00:01 +0000
committerDaniel Berlin <dberlin@gcc.gnu.org>2004-10-23 18:00:01 +0000
commit84dd478f2b83f54ebb2577a751c7d2b31bdc5c21 (patch)
treed5d749747f359eaf8ed7298e51dda7810c2e1aa8
parentee742c05a25dc4f364c345b1675203c402a5cda4 (diff)
downloadgcc-84dd478f2b83f54ebb2577a751c7d2b31bdc5c21.zip
gcc-84dd478f2b83f54ebb2577a751c7d2b31bdc5c21.tar.gz
gcc-84dd478f2b83f54ebb2577a751c7d2b31bdc5c21.tar.bz2
tree-ssa-dom.c (record_equality): Use loop depth to determine which way to record the equality as well.
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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-ssa-dom.c34
2 files changed, 38 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fa86a45..10a63b3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index c74537c..edd74e0 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -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;