aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-10-04 09:52:26 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-10-04 09:52:26 +0200
commit8a8e744eb2f8974501e73e92d5a698c48adf7d2a (patch)
treecb4ca464229d50c564e5a30a0ab52a06a2b2a2d2 /gcc
parent5c38262d95bedc091083cc881d9e21cd1f215a9a (diff)
downloadgcc-8a8e744eb2f8974501e73e92d5a698c48adf7d2a.zip
gcc-8a8e744eb2f8974501e73e92d5a698c48adf7d2a.tar.gz
gcc-8a8e744eb2f8974501e73e92d5a698c48adf7d2a.tar.bz2
re PR tree-optimization/82381 (internal compiler error: qsort checking failed)
PR tree-optimization/82381 * tree-ssa-reassoc.c (sort_by_operand_rank): Check for different oeN->rank first. Return 1 or -1 if one op is SSA_NAME and the other is not. From-SVN: r253396
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree-ssa-reassoc.c80
2 files changed, 46 insertions, 39 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3512f9e..075aeaf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2017-10-04 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/82381
+ * tree-ssa-reassoc.c (sort_by_operand_rank): Check for different
+ oeN->rank first. Return 1 or -1 if one op is SSA_NAME and the other
+ is not.
+
PR tree-optimization/82374
* omp-low.c (create_omp_child_function): Copy DECL_ATTRIBUTES,
DECL_FUNCTION_SPECIFIC_OPTIMIZATION,
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index eff76d1..cc57ae3 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -495,10 +495,13 @@ sort_by_operand_rank (const void *pa, const void *pb)
const operand_entry *oea = *(const operand_entry *const *)pa;
const operand_entry *oeb = *(const operand_entry *const *)pb;
+ if (oeb->rank != oea->rank)
+ return oeb->rank > oea->rank ? 1 : -1;
+
/* It's nicer for optimize_expression if constants that are likely
- to fold when added/multiplied//whatever are put next to each
+ to fold when added/multiplied/whatever are put next to each
other. Since all constants have rank 0, order them by type. */
- if (oeb->rank == 0 && oea->rank == 0)
+ if (oea->rank == 0)
{
if (constant_type (oeb->op) != constant_type (oea->op))
return constant_type (oeb->op) - constant_type (oea->op);
@@ -508,51 +511,50 @@ sort_by_operand_rank (const void *pa, const void *pb)
return oeb->id > oea->id ? 1 : -1;
}
+ if (TREE_CODE (oea->op) != SSA_NAME)
+ {
+ if (TREE_CODE (oeb->op) != SSA_NAME)
+ return oeb->id > oea->id ? 1 : -1;
+ else
+ return 1;
+ }
+ else if (TREE_CODE (oeb->op) != SSA_NAME)
+ return -1;
+
/* Lastly, make sure the versions that are the same go next to each
other. */
- if (oeb->rank == oea->rank
- && TREE_CODE (oea->op) == SSA_NAME
- && TREE_CODE (oeb->op) == SSA_NAME)
+ if (SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op))
{
- if (SSA_NAME_VERSION (oeb->op) != SSA_NAME_VERSION (oea->op))
+ /* 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. */
+ 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)
{
- /* 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. */
- 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)
- {
- /* One of the SSA_NAMEs can be defined in oeN->stmt_to_insert
- but the other might not. */
- if (!bba)
- return 1;
- if (!bbb)
- return -1;
- /* If neither is, compare bb_rank. */
- if (bb_rank[bbb->index] != bb_rank[bba->index])
- return bb_rank[bbb->index] - bb_rank[bba->index];
- }
+ /* One of the SSA_NAMEs can be defined in oeN->stmt_to_insert
+ but the other might not. */
+ if (!bba)
+ return 1;
+ if (!bbb)
+ return -1;
+ /* If neither is, compare bb_rank. */
+ if (bb_rank[bbb->index] != bb_rank[bba->index])
+ return bb_rank[bbb->index] - bb_rank[bba->index];
+ }
- 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;
+ 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;
- return (SSA_NAME_VERSION (oeb->op) > SSA_NAME_VERSION (oea->op)
- ? 1 : -1);
- }
- else
- return oeb->id > oea->id ? 1 : -1;
+ return SSA_NAME_VERSION (oeb->op) > SSA_NAME_VERSION (oea->op) ? 1 : -1;
}
- if (oeb->rank != oea->rank)
- return oeb->rank > oea->rank ? 1 : -1;
- else
- return oeb->id > oea->id ? 1 : -1;
+ return oeb->id > oea->id ? 1 : -1;
}
/* Add an operand entry to *OPS for the tree operand OP. */