diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-04-02 19:51:52 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-04-02 19:51:52 +0000 |
commit | aa7e537c6a038e81382606468e484576c2cee3d5 (patch) | |
tree | 149b47cc2c398d20f882c4307d0f320170375137 /gcc/tree-ssa-reassoc.c | |
parent | 7f646368a7a7679a8c4a349c4130b49d9a64d9cd (diff) | |
parent | b28b448fdb7865fc64094a799dd396f0d732a7c2 (diff) | |
download | gcc-aa7e537c6a038e81382606468e484576c2cee3d5.tar.gz |
Merge in trunk.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@209030 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r-- | gcc/tree-ssa-reassoc.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 5defb0a0ee0..ab784fab352 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -219,6 +219,7 @@ static struct pointer_map_t *operand_rank; /* Forward decls. */ static long get_rank (tree); +static bool reassoc_stmt_dominates_stmt_p (gimple, gimple); /* Bias amount for loop-carried phis. We want this to be larger than @@ -506,11 +507,37 @@ sort_by_operand_rank (const void *pa, const void *pb) } /* Lastly, make sure the versions that are the same go next to each - other. We use SSA_NAME_VERSION because it's stable. */ + other. */ if ((oeb->rank - oea->rank == 0) && TREE_CODE (oea->op) == SSA_NAME && TREE_CODE (oeb->op) == SSA_NAME) { + /* As SSA_NAME_VERSION is assigned pretty randomly, because we reuse + versions of removed SSA_NAMEs, so if possible, prefer to sort + based on basic block and gimple_uid of the SSA_NAME_DEF_STMT. + See PR60418. */ + if (!SSA_NAME_IS_DEFAULT_DEF (oea->op) + && !SSA_NAME_IS_DEFAULT_DEF (oeb->op) + && SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op)) + { + gimple stmta = SSA_NAME_DEF_STMT (oea->op); + gimple stmtb = SSA_NAME_DEF_STMT (oeb->op); + basic_block bba = gimple_bb (stmta); + basic_block bbb = gimple_bb (stmtb); + if (bbb != bba) + { + if (bb_rank[bbb->index] != bb_rank[bba->index]) + return bb_rank[bbb->index] - bb_rank[bba->index]; + } + else + { + bool da = reassoc_stmt_dominates_stmt_p (stmta, stmtb); + bool db = reassoc_stmt_dominates_stmt_p (stmtb, stmta); + if (da != db) + return da ? 1 : -1; + } + } + if (SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op)) return SSA_NAME_VERSION (oeb->op) - SSA_NAME_VERSION (oea->op); else @@ -806,8 +833,7 @@ eliminate_not_pairs (enum tree_code opcode, if (opcode == BIT_AND_EXPR) oe->op = build_zero_cst (TREE_TYPE (oe->op)); else if (opcode == BIT_IOR_EXPR) - oe->op = build_low_bits_mask (TREE_TYPE (oe->op), - TYPE_PRECISION (TREE_TYPE (oe->op))); + oe->op = build_all_ones_cst (TREE_TYPE (oe->op)); reassociate_stats.ops_eliminated += ops->length () - 1; ops->truncate (0); @@ -1840,7 +1866,8 @@ init_range_entry (struct range_entry *r, tree exp, gimple stmt) if (exp != NULL_TREE) { - if (TREE_CODE (exp) != SSA_NAME) + if (TREE_CODE (exp) != SSA_NAME + || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (exp)) break; stmt = SSA_NAME_DEF_STMT (exp); |