aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-07-16 07:19:24 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-07-16 07:19:24 +0000
commit612b9d1364bbefb708245c6cd5b5bfa2718926e6 (patch)
tree9c87181ff8efc2ef85a2ee497faa4320ecf25ed8 /gcc
parent4c3b378b5a9ddba3a66fa24203df5e850b4de3d6 (diff)
downloadgcc-612b9d1364bbefb708245c6cd5b5bfa2718926e6.zip
gcc-612b9d1364bbefb708245c6cd5b5bfa2718926e6.tar.gz
gcc-612b9d1364bbefb708245c6cd5b5bfa2718926e6.tar.bz2
tree-ssa-dom.c (dom_valueize): New function.
2015-07-16 Richard Biener <rguenther@suse.de> * tree-ssa-dom.c (dom_valueize): New function. (record_temporary_equivalences): Also record equivalences for dominating stmts that have uses of equivalences we are about to record. From-SVN: r225860
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-ssa-dom.c50
2 files changed, 56 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8e38205..47c7c16 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-07-16 Richard Biener <rguenther@suse.de>
+
+ * tree-ssa-dom.c (dom_valueize): New function.
+ (record_temporary_equivalences): Also record equivalences
+ for dominating stmts that have uses of equivalences we are
+ about to record.
+
2015-07-16 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (add_candidate): Remove call to
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 77f4ac0..3eb003c 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1401,6 +1401,20 @@ simplify_stmt_for_jump_threading (gimple stmt,
return lookup_avail_expr (stmt, false);
}
+/* Valueize hook for gimple_fold_stmt_to_constant_1. */
+
+static tree
+dom_valueize (tree t)
+{
+ if (TREE_CODE (t) == SSA_NAME)
+ {
+ tree tem = SSA_NAME_VALUE (t);
+ if (tem)
+ return tem;
+ }
+ return t;
+}
+
/* Record into the equivalence tables any equivalences implied by
traversing edge E (which are cached in E->aux).
@@ -1428,7 +1442,6 @@ record_temporary_equivalences (edge e)
additional equivalences. */
if (lhs
&& TREE_CODE (lhs) == SSA_NAME
- && is_gimple_constant (rhs)
&& TREE_CODE (rhs) == INTEGER_CST)
{
gimple defstmt = SSA_NAME_DEF_STMT (lhs);
@@ -1456,6 +1469,41 @@ record_temporary_equivalences (edge e)
}
}
+ /* If LHS is an SSA_NAME with a new equivalency then try if
+ stmts with uses of that LHS that dominate the edge destination
+ simplify and allow further equivalences to be recorded. */
+ if (lhs && TREE_CODE (lhs) == SSA_NAME)
+ {
+ use_operand_p use_p;
+ imm_use_iterator iter;
+ FOR_EACH_IMM_USE_FAST (use_p, iter, lhs)
+ {
+ gimple use_stmt = USE_STMT (use_p);
+
+ /* Only bother to record more equivalences for lhs that
+ can be directly used by e->dest.
+ ??? If the code gets re-organized to a worklist to
+ catch more indirect opportunities and it is made to
+ handle PHIs then this should only consider use_stmts
+ in basic-blocks we have already visited. */
+ if (e->dest == gimple_bb (use_stmt)
+ || !dominated_by_p (CDI_DOMINATORS,
+ e->dest, gimple_bb (use_stmt)))
+ continue;
+ tree lhs2 = gimple_get_lhs (use_stmt);
+ if (lhs2 && TREE_CODE (lhs2) == SSA_NAME)
+ {
+ tree res
+ = gimple_fold_stmt_to_constant_1 (use_stmt, dom_valueize,
+ no_follow_ssa_edges);
+ if (res
+ && (TREE_CODE (res) == SSA_NAME
+ || is_gimple_min_invariant (res)))
+ record_equality (lhs2, res);
+ }
+ }
+ }
+
/* If we have 0 = COND or 1 = COND equivalences, record them
into our expression hash tables. */
for (i = 0; edge_info->cond_equivalences.iterate (i, &eq); ++i)