diff options
author | Richard Biener <rguenther@suse.de> | 2020-11-19 12:28:41 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-11-19 13:27:55 +0100 |
commit | b08e0ee3018f2b5cbda7e6e54328f8e0b203e4be (patch) | |
tree | 8ae0963c1183a0f8be85d79d8bee2a43dd1ab975 /gcc | |
parent | d8cf89767492a41b0f76e0aa302dddee4e1b3434 (diff) | |
download | gcc-b08e0ee3018f2b5cbda7e6e54328f8e0b203e4be.zip gcc-b08e0ee3018f2b5cbda7e6e54328f8e0b203e4be.tar.gz gcc-b08e0ee3018f2b5cbda7e6e54328f8e0b203e4be.tar.bz2 |
refactor reassocs get_rank
This refactors things so assigned ranks are dumped and the cache
is consistently used also for PHIs.
2020-11-19 Richard Biener <rguenther@suse.de>
* tree-ssa-reassoc.c (get_rank): Refactor to consistently
use the cache and dump ranks assigned.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index a2ca171..89adafa 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -425,41 +425,43 @@ get_rank (tree e) long rank; tree op; - if (SSA_NAME_IS_DEFAULT_DEF (e)) - return find_operand_rank (e); - - stmt = SSA_NAME_DEF_STMT (e); - if (gimple_code (stmt) == GIMPLE_PHI) - return phi_rank (stmt); - - if (!is_gimple_assign (stmt)) - return bb_rank[gimple_bb (stmt)->index]; - /* If we already have a rank for this expression, use that. */ rank = find_operand_rank (e); if (rank != -1) return rank; - /* Otherwise, find the maximum rank for the operands. As an - exception, remove the bias from loop-carried phis when propagating - the rank so that dependent operations are not also biased. */ - /* Simply walk over all SSA uses - this takes advatage of the - fact that non-SSA operands are is_gimple_min_invariant and - thus have rank 0. */ - rank = 0; - FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE) - rank = propagate_rank (rank, op); + stmt = SSA_NAME_DEF_STMT (e); + if (gimple_code (stmt) == GIMPLE_PHI) + rank = phi_rank (stmt); + + else if (!is_gimple_assign (stmt)) + rank = bb_rank[gimple_bb (stmt)->index]; + + else + { + /* Otherwise, find the maximum rank for the operands. As an + exception, remove the bias from loop-carried phis when propagating + the rank so that dependent operations are not also biased. */ + /* Simply walk over all SSA uses - this takes advatage of the + fact that non-SSA operands are is_gimple_min_invariant and + thus have rank 0. */ + rank = 0; + FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE) + rank = propagate_rank (rank, op); + + rank += 1; + } if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Rank for "); print_generic_expr (dump_file, e); - fprintf (dump_file, " is %ld\n", (rank + 1)); + fprintf (dump_file, " is %ld\n", rank); } /* Note the rank in the hashtable so we don't recompute it. */ - insert_operand_rank (e, (rank + 1)); - return (rank + 1); + insert_operand_rank (e, rank); + return rank; } /* Constants, globals, etc., are rank 0 */ |