From: Peter Xu <peter.cose.seu@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Confused by the annotation in should_replace_address, a mistake ???
Date: Thu, 09 Jan 2014 13:52:00 -0000 [thread overview]
Message-ID: <1389275523534-1001116.post@n5.nabble.com> (raw)
Here is the code in fwprop.c:
/* OLD is a memory address. Return whether it is good to use NEW instead,
for a memory access in the given MODE. */
static bool
should_replace_address (rtx old_rtx, rtx new_rtx, enum machine_mode mode,
addr_space_t as, bool speed)
{
int gain;
if (rtx_equal_p (old_rtx, new_rtx)
|| !memory_address_addr_space_p (mode, new_rtx, as))
return false;
/* Copy propagation is always ok. */
if (REG_P (old_rtx) && REG_P (new_rtx))
return true;
* /* Prefer the new address if it is less expensive. */
gain = (address_cost (old_rtx, mode, as, speed)
- address_cost (new_rtx, mode, as, speed));
/* If the addresses have equivalent cost, prefer the new address
if it has the highest `set_src_cost'. That has the potential of
eliminating the most insns without additional costs, and it
is the same that cse.c used to do. */
if (gain == 0)
gain = set_src_cost (new_rtx, speed) - set_src_cost (old_rtx, speed);
return (gain > 0);*
}
According to the annotation, the 'return (gain > 0)' shouldn't be 'return
(gain >= 0)' ?
Here is the case for forward_addr.
insn set r155
plus r167 + 32
insn set mem (155)
r188
insn set mem (plus r155 + 8)
r189
......
If it is handled by the original code,
the result will be:
insn set r155
plus r167 + 32
insn set mem (r167 + 32)
r188
insn set mem (plus r155 + 8)
r189
However it is expected to be:
insn set mem (r167 + 32)
r188
insn set mem (plus r167 + 40)
r189
As the cost of 'addr r155' + 8 is equal to 'addr r167 + 40', so I think that
we should preffer to take the new addr, technically will be profitable ???
Brs,
Peter Xu.
-----
Dying in the sun.
--
View this message in context: http://gcc.1065356.n5.nabble.com/Confused-by-the-annotation-in-should-replace-address-a-mistake-tp1001116.html
Sent from the gcc - Help mailing list archive at Nabble.com.
reply other threads:[~2014-01-09 13:52 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=1389275523534-1001116.post@n5.nabble.com \
--to=peter.cose.seu@gmail.com \
--cc=gcc-help@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).