Message ID | VI1PR0801MB2031738FE8668029BAE25C69FF170@VI1PR0801MB2031.eurprd08.prod.outlook.com |
---|---|
State | New |
Headers | show |
On 05/02/2017 08:34 AM, Tamar Christina wrote: > Hi all, > > When comparing costs, the rtl function costs_lt_p compares the costs of > A and B such that if they are the same and we were checking for speed, > compare the size and use that as determining factor. > > This applies the same principle to the comparison done for the costing > of expr expansions. Potentially makes -Osize code faster and -Ospeed code > smaller. > > Bootstrapped on aarch64-none-linux-gnu and x86_64-linux > and reg-tested on aarch64-none-linux-gnu with no regressions. > > OK for trunk? > > Thanks, > Tamar > > > gcc/ > 2017-04-26 Tamar Christina <tamar.christina@arm.com> > > * expr.c (expand_expr_real_2): Re-cost if previous costs are the same. OK jeff
diff --git a/gcc/expr.c b/gcc/expr.c index 00f08aad55c90a0563bf93cf578107fe0b871231..2469608311c6793a58e7a042f751f390341242b4 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8837,6 +8837,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);