From: Uros Bizjak <ubizjak@gmail.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH, i386]: Improve constant RTX costs a bit
Date: Fri, 20 May 2016 17:42:00 -0000 [thread overview]
Message-ID: <CAFULd4ZX5nk6AENmU1fWAqkpWfb_SuyNCmy9U=HodsoRYPoWyg@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
2016-05-20 Uros Bizjak <ubizjak@gmail.com>
* gcc/config/i386/i386.c (ix86_rtx_costs) <case CONST_DOUBLE>:
Use IS_STACK_MODE when calculating cost of standard 80387 constants.
Fallthru to CONST_VECTOR case to calculate cost of standard SSE
constants.
<case CONST_WIDE_INT>: Calculate cost of (MEM (SYMBOL_REF)).
(ix86_legitimate_constant_p): Use CASE_CONST_SCALAR_INT
and CASE_CONST_ANY.
Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to mainline SVN.
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 2673 bytes --]
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index cecea11..26ec3cb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -14864,8 +14864,7 @@ ix86_legitimate_constant_p (machine_mode mode, rtx x)
#endif
break;
- case CONST_INT:
- case CONST_WIDE_INT:
+ CASE_CONST_SCALAR_INT:
switch (mode)
{
case TImode:
@@ -14900,18 +14899,16 @@ ix86_legitimate_constant_p (machine_mode mode, rtx x)
static bool
ix86_cannot_force_const_mem (machine_mode mode, rtx x)
{
- /* We can always put integral constants and vectors in memory. */
+ /* We can put any immediate constant in memory. */
switch (GET_CODE (x))
{
- case CONST_INT:
- case CONST_WIDE_INT:
- case CONST_DOUBLE:
- case CONST_VECTOR:
+ CASE_CONST_ANY:
return false;
default:
break;
}
+
return !ix86_legitimate_constant_p (mode, x);
}
@@ -44073,43 +44070,43 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno,
*total = 0;
return true;
- case CONST_WIDE_INT:
- *total = 0;
- return true;
-
case CONST_DOUBLE:
- switch (standard_80387_constant_p (x))
+ if (TARGET_80387 && IS_STACK_MODE (mode))
+ switch (standard_80387_constant_p (x))
+ {
+ case -1:
+ case 0:
+ break;
+ case 1: /* 0.0 */
+ *total = 1;
+ return true;
+ default: /* Other constants */
+ *total = 2;
+ return true;
+ }
+ /* FALLTHRU */
+
+ case CONST_VECTOR:
+ switch (standard_sse_constant_p (x, mode))
{
- case 1: /* 0.0 */
- *total = 1;
- return true;
- default: /* Other constants */
- *total = 2;
- return true;
case 0:
- case -1:
break;
+ case 1: /* 0: xor eliminates false dependency */
+ *total = 0;
+ return true;
+ default: /* -1: cmp contains false dependency */
+ *total = 1;
+ return true;
}
- if (SSE_FLOAT_MODE_P (mode))
- {
- case CONST_VECTOR:
- switch (standard_sse_constant_p (x, mode))
- {
- case 0:
- break;
- case 1: /* 0: xor eliminates false dependency */
- *total = 0;
- return true;
- default: /* -1: cmp contains false dependency */
- *total = 1;
- return true;
- }
- }
+ /* FALLTHRU */
+
+ case CONST_WIDE_INT:
/* Fall back to (MEM (SYMBOL_REF)), since that's where
it'll probably end up. Add a penalty for size. */
*total = (COSTS_N_INSNS (1)
- + (flag_pic != 0 && !TARGET_64BIT)
- + (mode == SFmode ? 0 : mode == DFmode ? 1 : 2));
+ + (!TARGET_64BIT && flag_pic)
+ + (GET_MODE_SIZE (mode) <= 4
+ ? 0 : GET_MODE_SIZE (mode) <= 8 ? 1 : 2));
return true;
case ZERO_EXTEND:
reply other threads:[~2016-05-20 17:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='CAFULd4ZX5nk6AENmU1fWAqkpWfb_SuyNCmy9U=HodsoRYPoWyg@mail.gmail.com' \
--to=ubizjak@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/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).