This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATH][GCC][mid-end] Check the alternate cost model just as costs_lt_p
- From: Tamar Christina <Tamar dot Christina at arm dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: nd <nd at arm dot com>, "law at redhat dot com" <law at redhat dot com>, "rguenther at suse dot de" <rguenther at suse dot de>, "ian at airs dot com" <ian at airs dot com>
- Date: Tue, 2 May 2017 14:34:38 +0000
- Subject: [PATH][GCC][mid-end] Check the alternate cost model just as costs_lt_p
- Authentication-results: sourceware.org; auth=none
- Authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
- Nodisclaimer: True
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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.
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);