From 9be7a86861676ae2f3808af2f255b009c12127fb Mon Sep 17 00:00:00 2001 From: tnfchris Date: Tue, 2 May 2017 15:20:47 +0000 Subject: [PATCH] 2017-04-26 Tamar Christina * expr.c (expand_expr_real_2): Re-cost if previous costs are the same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@247505 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 ++++ gcc/expr.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 00f21e71c5d..b177645b802 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-04-26 Tamar Christina + + * expr.c (expand_expr_real_2): Re-cost if previous costs are the same. + 2017-04-27 Tamar Christina * simplify-rtx.c (simplify_binary_operation_1): Add LSHIFTRT case. diff --git a/gcc/expr.c b/gcc/expr.c index c5c50e015ad..4749cc508b8 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8838,6 +8838,15 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode, end_sequence (); unsigned uns_cost = seq_cost (uns_insns, speed_p); unsigned sgn_cost = seq_cost (sgn_insns, speed_p); + + /* If costs are the same then use as tie breaker the other + other factor. */ + if (uns_cost == sgn_cost) + { + uns_cost = seq_cost (uns_insns, !speed_p); + sgn_cost = seq_cost (sgn_insns, !speed_p); + } + if (uns_cost < sgn_cost || (uns_cost == sgn_cost && unsignedp)) { emit_insn (uns_insns); -- 2.11.4.GIT