From: Kyrill Tkachov <kyrylo.tkachov@arm.com>
To: Bernd Schmidt <bschmidt@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
richard.sandiford@arm.com
Subject: Re: [PATCH][auto-inc-dec.c] Account for cost of move operation in FORM_PRE_ADD and FORM_POST_ADD cases
Date: Mon, 26 Oct 2015 11:55:00 -0000 [thread overview]
Message-ID: <562E13EC.3010305@arm.com> (raw)
In-Reply-To: <562E0E48.1020603@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 640 bytes --]
On 26/10/15 11:28, Bernd Schmidt wrote:
> On 10/26/2015 12:12 PM, Bernd Schmidt wrote:
>>
>> But isn't that balanced by the fact that it doesn't seem to take into
>> account the gain of removing the inc_insn either? So I think this can't
>> be right.
>
> Argh, misread the code. The patch is OK with the change I suggested.
>
Thanks!
Here's what I committed with r229344.
Kyrill
2015-10-26 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
* auto-inc-dec.c (insert_move_insn_before): Delete.
(attempt_change): Remember to cost the simple move in the
FORM_PRE_ADD and FORM_POST_ADD cases.
>
> Bernd
>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: autoincdec-costs.patch --]
[-- Type: text/x-patch; name=autoincdec-costs.patch, Size: 2796 bytes --]
commit cc7c4748eac1f9d59ceb5393132c098aba99765d
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date: Fri Oct 16 13:46:51 2015 +0100
[auto-inc-dec.c] Account for cost of move operation in FORM_PRE_ADD and FORM_POST_ADD cases
diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c
index e003b13..9f7c8e0 100644
--- a/gcc/auto-inc-dec.c
+++ b/gcc/auto-inc-dec.c
@@ -439,24 +439,6 @@ move_dead_notes (rtx_insn *to_insn, rtx_insn *from_insn, rtx pattern)
}
}
-
-/* Create a mov insn DEST_REG <- SRC_REG and insert it before
- NEXT_INSN. */
-
-static rtx_insn *
-insert_move_insn_before (rtx_insn *next_insn, rtx dest_reg, rtx src_reg)
-{
- rtx_insn *insns;
-
- start_sequence ();
- emit_move_insn (dest_reg, src_reg);
- insns = get_insns ();
- end_sequence ();
- emit_insn_before (insns, next_insn);
- return insns;
-}
-
-
/* Change mem_insn.mem_loc so that uses NEW_ADDR which has an
increment of INC_REG. To have reached this point, the change is a
legitimate one from a dataflow point of view. The only questions
@@ -490,8 +472,21 @@ attempt_change (rtx new_addr, rtx inc_reg)
old_cost = (set_src_cost (mem, mode, speed)
+ set_rtx_cost (PATTERN (inc_insn.insn), speed));
+
new_cost = set_src_cost (mem_tmp, mode, speed);
+ /* In the FORM_PRE_ADD and FORM_POST_ADD cases we emit an extra move
+ whose cost we should account for. */
+ if (inc_insn.form == FORM_PRE_ADD
+ || inc_insn.form == FORM_POST_ADD)
+ {
+ start_sequence ();
+ emit_move_insn (inc_insn.reg_res, inc_insn.reg0);
+ mov_insn = get_insns ();
+ end_sequence ();
+ new_cost += seq_cost (mov_insn, speed);
+ }
+
/* The first item of business is to see if this is profitable. */
if (old_cost < new_cost)
{
@@ -522,8 +517,8 @@ attempt_change (rtx new_addr, rtx inc_reg)
/* Replace the addition with a move. Do it at the location of
the addition since the operand of the addition may change
before the memory reference. */
- mov_insn = insert_move_insn_before (inc_insn.insn,
- inc_insn.reg_res, inc_insn.reg0);
+ gcc_assert (mov_insn);
+ emit_insn_before (mov_insn, inc_insn.insn);
move_dead_notes (mov_insn, inc_insn.insn, inc_insn.reg0);
regno = REGNO (inc_insn.reg_res);
@@ -548,8 +543,8 @@ attempt_change (rtx new_addr, rtx inc_reg)
break;
case FORM_POST_ADD:
- mov_insn = insert_move_insn_before (mem_insn.insn,
- inc_insn.reg_res, inc_insn.reg0);
+ gcc_assert (mov_insn);
+ emit_insn_before (mov_insn, mem_insn.insn);
move_dead_notes (mov_insn, inc_insn.insn, inc_insn.reg0);
/* Do not move anything to the mov insn because the instruction
next prev parent reply other threads:[~2015-10-26 11:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 10:41 Kyrill Tkachov
2015-10-26 11:14 ` Bernd Schmidt
2015-10-26 11:28 ` Bernd Schmidt
2015-10-26 11:55 ` Kyrill Tkachov [this message]
2015-10-28 17:26 ` Christophe Lyon
2015-10-28 17:47 ` Kyrill Tkachov
2015-10-29 15:54 ` Kyrill Tkachov
2015-10-26 12:26 ` Oleg Endo
2015-10-26 16:12 ` Richard Sandiford
2015-10-26 21:48 ` 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=562E13EC.3010305@arm.com \
--to=kyrylo.tkachov@arm.com \
--cc=bschmidt@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.sandiford@arm.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).