public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tamar Christina <Tamar.Christina@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: nd <nd@arm.com>, "law@redhat.com" <law@redhat.com>,
	"rguenther@suse.de"	<rguenther@suse.de>,
	"ian@airs.com" <ian@airs.com>
Subject: [PATH][GCC][mid-end] Check the alternate cost model just as costs_lt_p
Date: Tue, 02 May 2017 14:34:00 -0000	[thread overview]
Message-ID: <VI1PR0801MB2031738FE8668029BAE25C69FF170@VI1PR0801MB2031.eurprd08.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: costs_lt_p.patch --]
[-- Type: text/x-patch; name="costs_lt_p.patch", Size: 734 bytes --]

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);


             reply	other threads:[~2017-05-02 14:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 14:34 Tamar Christina [this message]
2017-05-02 15:21 ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR0801MB2031738FE8668029BAE25C69FF170@VI1PR0801MB2031.eurprd08.prod.outlook.com \
    --to=tamar.christina@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ian@airs.com \
    --cc=law@redhat.com \
    --cc=nd@arm.com \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).