From a59d8e8eb67086eb6df936074ef6d8fb4834bcc2 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 8 Jul 2014 09:22:54 +0000 Subject: [PATCH] tree-ssa-dom.h (loop_depth_of_name): Remove. 2014-07-08 Richard Biener * tree-ssa-dom.h (loop_depth_of_name): Remove. * tree-ssa-dom.c (record_equivalences_from_phis): Remove restriction on loop depth difference. (record_equality): Likewise. (propagate_rhs_into_lhs): Likewise. Simplify condition. (loop_depth_of_name): Remove. * tree-ssa-copy.c (copy_prop_visit_phi_node): Remove restriction on loop depth difference. (init_copy_prop): Likewise. * gcc.dg/tree-ssa/ssa-pre-16.c: Adjust expected eliminations. From-SVN: r212352 --- gcc/ChangeLog | 12 ++++++ gcc/testsuite/ChangeLog | 12 ++++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-16.c | 2 +- gcc/tree-ssa-copy.c | 30 ++++---------- gcc/tree-ssa-dom.c | 46 ++-------------------- gcc/tree-ssa-dom.h | 1 - 6 files changed, 36 insertions(+), 67 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 084aa13494e..f333d614847 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2014-07-08 Richard Biener + + * tree-ssa-dom.h (loop_depth_of_name): Remove. + * tree-ssa-dom.c (record_equivalences_from_phis): Remove + restriction on loop depth difference. + (record_equality): Likewise. + (propagate_rhs_into_lhs): Likewise. Simplify condition. + (loop_depth_of_name): Remove. + * tree-ssa-copy.c (copy_prop_visit_phi_node): Remove + restriction on loop depth difference. + (init_copy_prop): Likewise. + 2014-07-08 Jan Hubicka * tree-ssa-alias.c (walk_aliased_vdefs_1): Add FUNCTION_ENTRY_REACHED diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 635f8ea179c..d933972ff5b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2014-07-08 Richard Biener + + * tree-ssa-dom.h (loop_depth_of_name): Remove. + * tree-ssa-dom.c (record_equivalences_from_phis): Remove + restriction on loop depth difference. + (record_equality): Likewise. + (propagate_rhs_into_lhs): Likewise. Simplify condition. + (loop_depth_of_name): Remove. + * tree-ssa-copy.c (copy_prop_visit_phi_node): Remove + restriction on loop depth difference. + (init_copy_prop): Likewise. + 2014-07-08 Richard Biener PR tree-optimization/61681 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-16.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-16.c index 7bc1dd3aab7..b087dc1b45c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-16.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-16.c @@ -11,5 +11,5 @@ int foo(int k, int *x) } while (++j loop_depth_of_name (lhs) - || (loops_state_satisfies_p (LOOP_CLOSED_SSA) - && loop_exit_edge_p (e->src->loop_father, e)))) + /* In loop-closed SSA form do not copy-propagate SSA-names across + loop exit edges. */ + if (loops_state_satisfies_p (LOOP_CLOSED_SSA) + && TREE_CODE (arg_value) == SSA_NAME + && loop_exit_edge_p (e->src->loop_father, e)) { phi_val.value = lhs; break; @@ -470,7 +466,6 @@ init_copy_prop (void) FOR_EACH_BB_FN (bb, cfun) { gimple_stmt_iterator si; - int depth = bb_loop_depth (bb); for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { @@ -481,21 +476,10 @@ init_copy_prop (void) /* The only statements that we care about are those that may generate useful copies. We also need to mark conditional jumps so that their outgoing edges are added to the work - lists of the propagator. - - Avoid copy propagation from an inner into an outer loop. - Otherwise, this may move loop variant variables outside of - their loops and prevent coalescing opportunities. If the - value was loop invariant, it will be hoisted by LICM and - exposed for copy propagation. - ??? This doesn't make sense. */ + lists of the propagator. */ if (stmt_ends_bb_p (stmt)) prop_set_simulate_again (stmt, true); - else if (stmt_may_generate_copy (stmt) - /* Since we are iterating over the statements in - BB, not the phi nodes, STMT will always be an - assignment. */ - && loop_depth_of_name (gimple_assign_rhs1 (stmt)) <= depth) + else if (stmt_may_generate_copy (stmt)) prop_set_simulate_again (stmt, true); else prop_set_simulate_again (stmt, false); diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 795ed09ae86..d0501a2d23d 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1235,12 +1235,7 @@ record_equivalences_from_phis (basic_block bb) inferred from a comparison. All uses of this ssa name are dominated by this assignment, so unwinding just costs time and space. */ if (i == gimple_phi_num_args (phi) - && may_propagate_copy (lhs, rhs) - /* Do not propagate copies if the propagated value is at a deeper loop - depth than the propagatee. Otherwise, this may introduce uses - of loop variant variables outside of their loops and prevent - coalescing opportunities. */ - && !(loop_depth_of_name (rhs) > loop_depth_of_name (lhs))) + && may_propagate_copy (lhs, rhs)) set_ssa_name_value (lhs, rhs); } } @@ -1575,33 +1570,6 @@ record_const_or_copy_1 (tree x, tree y, tree prev_x) const_and_copies_stack.quick_push (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. */ - -int -loop_depth_of_name (tree x) -{ - gimple 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 = gimple_bb (defstmt); - if (!defbb) - return 0; - - return bb_loop_depth (defbb); -} - /* Record that X is equal to Y in const_and_copies. Record undo information in the block-local vector. */ @@ -1641,8 +1609,7 @@ record_equality (tree x, tree y) long as we canonicalize on one value. */ if (is_gimple_min_invariant (y)) ; - else if (is_gimple_min_invariant (x) - || (loop_depth_of_name (x) <= loop_depth_of_name (y))) + else if (is_gimple_min_invariant (x)) prev_x = x, x = y, y = prev_x, prev_x = prev_y; else if (prev_x && is_gimple_min_invariant (prev_x)) x = y, y = prev_x, prev_x = prev_y; @@ -2686,13 +2653,8 @@ get_lhs_or_phi_result (gimple stmt) static void propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_names) { - /* First verify that propagation is valid and isn't going to move a - loop variant variable outside its loop. */ - if (! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs) - && (TREE_CODE (rhs) != SSA_NAME - || ! SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)) - && may_propagate_copy (lhs, rhs) - && loop_depth_of_name (lhs) >= loop_depth_of_name (rhs)) + /* First verify that propagation is valid. */ + if (may_propagate_copy (lhs, rhs)) { use_operand_p use_p; imm_use_iterator iter; diff --git a/gcc/tree-ssa-dom.h b/gcc/tree-ssa-dom.h index af2f128c819..604c7c1376a 100644 --- a/gcc/tree-ssa-dom.h +++ b/gcc/tree-ssa-dom.h @@ -22,7 +22,6 @@ along with GCC; see the file COPYING3. If not see extern void dump_dominator_optimization_stats (FILE *); extern void debug_dominator_optimization_stats (void); -extern int loop_depth_of_name (tree); extern bool simple_iv_increment_p (gimple); #endif /* GCC_TREE_SSA_DOM_H */