From: Richard Sandiford <richard@codesourcery.com>
To: Sandra Loosemore <sandra@codesourcery.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Nigel Stephens <nigel@mips.com>, Guy Morrogh <guym@mips.com>,
David Ung <davidu@mips.com>, Thiemo Seufer <ths@mips.com>
Subject: Re: PATCH: fine-tuning for can_store_by_pieces
Date: Thu, 16 Aug 2007 08:34:00 -0000 [thread overview]
Message-ID: <87ps1nop2x.fsf@firetop.home> (raw)
In-Reply-To: <46C3343A.5080407@codesourcery.com> (Sandra Loosemore's message of "Wed\, 15 Aug 2007 13\:13\:30 -0400")
I'll leave the target-independent bits to the appropriate maintainers.
As far as the MIPS bits go:
Sandra Loosemore <sandra@codesourcery.com> writes:
> + /* Define MOVE_RATIO to encourage use of movmemsi when enabled,
> + since it should always generate code at least as good as
> + move_by_pieces(). But when inline movmemsi pattern is disabled
> + (i.e., with -mips16 or -mmemcpy), instead represent the length of
> + a memcpy call sequence (~6 insns), so that move_by_pieces will
> + generate inline code if it is shorter than a function call.
> + Note that move_by_pieces_ninsns() counts memory-to-memory moves,
> + but we'll have to generate a load/store pair for each, so further
> + halve the value to take that into account. */
> +
> + #define MOVE_RATIO ((TARGET_MIPS16 || TARGET_MEMCPY) ? 3 : 2)
The TARGET_MIPS16 || TARGET_MEMCPY case is fine, and nicely described,
but it would be good to have a comment explaining why 2 encourages
"use of movmemsi when enabled".
> + /* For CLEAR_RATIO use a better estimate of the length of a memset
> + call when optimizing for size. */
> +
> + #define CLEAR_RATIO (optimize_size ? 5 : 15)
Might be worth emphasising that 15 is the default for !optimize_size,
as it otherwise isn't clear where that number came from.
> + /* This is similar to CLEAR_RATIO, but for a non-zero constant, so when
> + optimizing for size adjust the ratio to account for the overhead of
> + loading the constant and replicating it across the word. In fact in
> + that case it is never worth inlining, since calling memset should
> + always be smaller. */
> +
> + #define SET_RATIO (optimize_size ? 3 : 15)
Is there a lower limit to the size of memsets for which SET_RATIO is
used? I'm not convinced that memset is smaller for power-of-2 stores up
to word or (if aligned) doubleword size. (I'm assuming here that we use
left/right stores for unaligned 4-byte and (on 64-bit targets) 8-byte
stores. If we don't, we should.)
Perhaps one of these days we should add a setmem pattern...
> + /* STORE_BY_PIECES_P can be used when copying a constant string, but
> + in that case each word takes 3 insns (lui, ori, sw), or more in
> + 64-bit mode, instead of 2 (lw, sw). So better to always fail this
> + and let the move_by_pieces code copy the string from read-only
> + memory. */
> +
> + #define STORE_BY_PIECES_P(SIZE, ALIGN) 0
However, lui/ori/sw could easily be better speedwise in some situations,
so should this be dependent on optimize_size too?
Finally, a general comment: the call costs seem to be based on *-elf
targets, where a direct call is allowed. The cost of a call is higher
sizewise for n32 and n64 abicalls. It is higher still for o32 abicalls,
where we have to restore $gp afterwards. (The cost for all three is even
higher if the function didn't otherwise need $gp, but I don't think we
can really account for that.)
Please check whether this patch fixes PR 11787. (It should, if the
cost are good.) If it does, add "PR target/11787" to the changelog.
Richard
next prev parent reply other threads:[~2007-08-16 8:34 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-15 17:15 Sandra Loosemore
2007-08-15 17:22 ` Andrew Pinski
2007-08-15 18:32 ` Sandra Loosemore
2007-08-15 19:53 ` Nigel Stephens
2007-08-15 19:58 ` Sandra Loosemore
2007-08-17 4:50 ` Mark Mitchell
2007-08-17 13:24 ` Sandra Loosemore
2007-08-17 18:55 ` Mark Mitchell
2007-08-16 8:34 ` Richard Sandiford [this message]
2007-08-16 19:41 ` Sandra Loosemore
2007-08-19 0:03 ` Sandra Loosemore
2007-08-20 8:22 ` Richard Sandiford
2007-08-20 23:38 ` Sandra Loosemore
2007-08-21 8:21 ` Richard Sandiford
2007-08-21 10:34 ` Nigel Stephens
2007-08-21 11:53 ` Richard Sandiford
2007-08-21 12:14 ` Nigel Stephens
2007-08-21 12:35 ` Richard Sandiford
2007-08-21 13:54 ` Sandra Loosemore
2007-08-21 14:22 ` Richard Sandiford
2007-08-21 20:39 ` Sandra Loosemore
2007-08-21 20:56 ` Richard Sandiford
2007-08-23 14:35 ` Sandra Loosemore
2007-08-23 14:44 ` Richard Sandiford
2007-08-25 5:35 ` [committed] " Sandra Loosemore
2007-08-25 9:18 ` Jakub Jelinek
2007-08-25 9:58 ` Jakub Jelinek
2007-08-25 14:30 ` gcc.c-torture/execute/20030221-1.c regressed with "fine-tuning for can_store_by_pieces" Hans-Peter Nilsson
2007-08-25 14:40 ` [committed] Re: PATCH: fine-tuning for can_store_by_pieces Sandra Loosemore
2007-08-24 22:06 ` Mark Mitchell
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=87ps1nop2x.fsf@firetop.home \
--to=richard@codesourcery.com \
--cc=davidu@mips.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guym@mips.com \
--cc=nigel@mips.com \
--cc=sandra@codesourcery.com \
--cc=ths@mips.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).