summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dom.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2006-04-03 11:08:42 -0600
committerJeff Law <law@gcc.gnu.org>2006-04-03 11:08:42 -0600
commitcbc75e6222900e5247774843699eea0c41c41cc8 (patch)
tree84dc8a6be3eb377b00a9178a3c11bd830efbe958 /gcc/tree-ssa-dom.c
parente47247850c490308bdc8986838a4005d4ce0ddf0 (diff)
downloadgcc-cbc75e6222900e5247774843699eea0c41c41cc8.tar.gz
tree-ssa-dom.c (propagate_rhs_into_lhs): Avoid useless folding and operand scanning in some common cases.
* tree-ssa-dom.c (propagate_rhs_into_lhs): Avoid useless folding and operand scanning in some common cases. From-SVN: r112642
Diffstat (limited to 'gcc/tree-ssa-dom.c')
-rw-r--r--gcc/tree-ssa-dom.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index f631eaaccd9..45034dd2ce7 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -2155,10 +2155,46 @@ propagate_rhs_into_lhs (tree stmt, tree lhs, tree rhs, bitmap interesting_names)
fprintf (dump_file, "\n");
}
- /* Propagate, fold and update the statement. Note this may
- expose new const/copy propagation opportunities as well
- collapse control statements. */
+ /* Propagate the RHS into this use of the LHS. */
propagate_value (use_p, rhs);
+
+ /* Special cases to avoid useless calls into the folding
+ routines, operand scanning, etc.
+
+ First, propagation into a PHI may cause the PHI to become
+ a degenerate, so mark the PHI as interesting. No other
+ actions are necessary.
+
+ Second, if we're propagating a virtual operand and the
+ propagation does not change the underlying _DECL node for
+ the virtual operand, then no further actions are necessary. */
+ if (TREE_CODE (use_stmt) == PHI_NODE
+ || (! is_gimple_reg (lhs)
+ && TREE_CODE (rhs) == SSA_NAME
+ && SSA_NAME_VAR (lhs) == SSA_NAME_VAR (rhs)))
+ {
+ /* Dump details. */
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, " Updated statement:");
+ print_generic_expr (dump_file, use_stmt, dump_flags);
+ fprintf (dump_file, "\n");
+ }
+
+ /* Propagation into a PHI may expose new degenerate PHIs,
+ so mark the result of the PHI as interesting. */
+ if (TREE_CODE (use_stmt) == PHI_NODE)
+ {
+ tree result = get_lhs_or_phi_result (use_stmt);
+ bitmap_set_bit (interesting_names, SSA_NAME_VERSION (result));
+ }
+ continue;
+ }
+
+ /* From this point onward we are propagating into a
+ real statement. Folding may (or may not) be possible,
+ we may expose new operands, expose dead EH edges,
+ etc. */
fold_stmt_inplace (use_stmt);
/* Sometimes propagation can expose new operands to the
@@ -2189,13 +2225,12 @@ propagate_rhs_into_lhs (tree stmt, tree lhs, tree rhs, bitmap interesting_names)
fprintf (dump_file, " Flagged to clear EH edges.\n");
}
- /* Propagation may expose new degenerate PHIs or
- trivial copy/constant propagation opportunities. */
- if (TREE_CODE (use_stmt) == PHI_NODE
- || (TREE_CODE (use_stmt) == MODIFY_EXPR
- && TREE_CODE (TREE_OPERAND (use_stmt, 0)) == SSA_NAME
- && (TREE_CODE (TREE_OPERAND (use_stmt, 1)) == SSA_NAME
- || is_gimple_min_invariant (TREE_OPERAND (use_stmt, 1)))))
+ /* Propagation may expose new trivial copy/constant propagation
+ opportunities. */
+ if (TREE_CODE (use_stmt) == MODIFY_EXPR
+ && TREE_CODE (TREE_OPERAND (use_stmt, 0)) == SSA_NAME
+ && (TREE_CODE (TREE_OPERAND (use_stmt, 1)) == SSA_NAME
+ || is_gimple_min_invariant (TREE_OPERAND (use_stmt, 1))))
{
tree result = get_lhs_or_phi_result (use_stmt);
bitmap_set_bit (interesting_names, SSA_NAME_VERSION (result));