From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Cc: law@redhat.com, Segher Boessenkool <segher@kernel.crashing.org>
Subject: [PATCH 2/3] combine: Use insn_cost instead of pattern_cost everywhere
Date: Mon, 09 Oct 2017 19:35:00 -0000 [thread overview]
Message-ID: <8d21a5dca23dd868427f3e4d81b24b09d84e2462.1507574244.git.segher@kernel.crashing.org> (raw)
In-Reply-To: <cafebcc0ecc2bac6cbfbb989369a437cfff768b2.1507574244.git.segher@kernel.crashing.org>
In-Reply-To: <cafebcc0ecc2bac6cbfbb989369a437cfff768b2.1507574244.git.segher@kernel.crashing.org>
Committing to trunk.
Segher
2017-10-09 Segher Boessenkool <segher@kernel.crashing.org>
* combine.c (combine_validate_cost): Compute the new insn_cost,
not just pattern_cost.
(try_combine): Adjust comment.
---
gcc/combine.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/gcc/combine.c b/gcc/combine.c
index c5f6a00..9a006be 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -856,7 +856,7 @@ combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3,
int new_i2_cost, new_i3_cost;
int old_cost, new_cost;
- /* Lookup the original insn_rtx_costs. */
+ /* Lookup the original insn_costs. */
i2_cost = INSN_COST (i2);
i3_cost = INSN_COST (i3);
@@ -888,11 +888,23 @@ combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3,
old_cost -= i1_cost;
- /* Calculate the replacement pattern_costs. */
- new_i3_cost = pattern_cost (newpat, optimize_this_for_speed_p);
+ /* Calculate the replacement insn_costs. */
+ rtx tmp = PATTERN (i3);
+ PATTERN (i3) = newpat;
+ int tmpi = INSN_CODE (i3);
+ INSN_CODE (i3) = -1;
+ new_i3_cost = insn_cost (i3, optimize_this_for_speed_p);
+ PATTERN (i3) = tmp;
+ INSN_CODE (i3) = tmpi;
if (newi2pat)
{
- new_i2_cost = pattern_cost (newi2pat, optimize_this_for_speed_p);
+ tmp = PATTERN (i2);
+ PATTERN (i2) = newi2pat;
+ tmpi = INSN_CODE (i2);
+ INSN_CODE (i2) = -1;
+ new_i2_cost = insn_cost (i2, optimize_this_for_speed_p);
+ PATTERN (i2) = tmp;
+ INSN_CODE (i2) = tmpi;
new_cost = (new_i2_cost > 0 && new_i3_cost > 0)
? new_i2_cost + new_i3_cost : 0;
}
@@ -907,7 +919,14 @@ combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3,
int old_other_cost, new_other_cost;
old_other_cost = INSN_COST (undobuf.other_insn);
- new_other_cost = pattern_cost (newotherpat, optimize_this_for_speed_p);
+ tmp = PATTERN (undobuf.other_insn);
+ PATTERN (undobuf.other_insn) = newotherpat;
+ tmpi = INSN_CODE (undobuf.other_insn);
+ INSN_CODE (undobuf.other_insn) = -1;
+ new_other_cost = insn_cost (undobuf.other_insn,
+ optimize_this_for_speed_p);
+ PATTERN (undobuf.other_insn) = tmp;
+ INSN_CODE (undobuf.other_insn) = tmpi;
if (old_other_cost > 0 && new_other_cost > 0)
{
old_cost += old_other_cost;
@@ -4108,7 +4127,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
}
}
- /* Only allow this combination if insn_rtx_costs reports that the
+ /* Only allow this combination if insn_cost reports that the
replacement instructions are cheaper than the originals. */
if (!combine_validate_cost (i0, i1, i2, i3, newpat, newi2pat, other_pat))
{
--
1.8.3.1
next prev parent reply other threads:[~2017-10-09 19:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 19:35 [PATCH 1/3] Replace insn_rtx_cost with insn_cost and pattern_cost Segher Boessenkool
2017-10-09 19:35 ` Segher Boessenkool [this message]
2017-10-09 19:48 ` [PATCH 3/3] Add targetm.insn_cost hook Segher Boessenkool
2017-10-11 23:48 ` Sandra Loosemore
2017-10-12 2:21 ` Segher Boessenkool
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=8d21a5dca23dd868427f3e4d81b24b09d84e2462.1507574244.git.segher@kernel.crashing.org \
--to=segher@kernel.crashing.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
/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).