From 5ac4b05631a3e93ab8630f82cf7e4763a46b8e69 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 1 Dec 2017 09:14:21 +0100 Subject: [PATCH] re PR tree-optimization/83221 (qsort comparator not anti-commutative: -2147483648, -2147483648) PR tree-optimization/83221 * tree-ssa-reassoc.c (sort_by_operand_rank): Shift bb_rank down by 16. (init_reassoc): Formatting fix. From-SVN: r255297 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-reassoc.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5ab9f6fab5f..46c4545efbe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2017-12-01 Jakub Jelinek + PR tree-optimization/83221 + * tree-ssa-reassoc.c (sort_by_operand_rank): Shift bb_rank + down by 16. + (init_reassoc): Formatting fix. + PR sanitizer/81275 * tree-cfg.c (group_case_labels_stmt): Don't optimize away C++ FE implicitly added __builtin_unreachable () until -Wreturn-type diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 5e8cac69d5d..485d0a692ce 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -543,7 +543,7 @@ sort_by_operand_rank (const void *pa, const void *pb) 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]; + return (bb_rank[bbb->index] >> 16) - (bb_rank[bba->index] >> 16); } bool da = reassoc_stmt_dominates_stmt_p (stmta, stmtb); @@ -6131,7 +6131,7 @@ init_reassoc (void) /* Set up rank for each BB */ for (i = 0; i < n_basic_blocks_for_fn (cfun) - NUM_FIXED_BLOCKS; i++) - bb_rank[bbs[i]] = ++rank << 16; + bb_rank[bbs[i]] = ++rank << 16; free (bbs); calculate_dominance_info (CDI_POST_DOMINATORS); -- 2.30.2