public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: Andrew Pinski <pinskia@gmail.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>,
	 Richard Sandiford <richard@codesourcery.com>
Subject: Re: PATCH: fine-tuning for can_store_by_pieces
Date: Wed, 15 Aug 2007 19:58:00 -0000	[thread overview]
Message-ID: <46C35A4B.1080105@codesourcery.com> (raw)
In-Reply-To: <de8d50360708151022v70179ea9xeefc109b25fa3eb2@mail.gmail.com>

Andrew Pinski wrote:

> It seems if you gave a testcase where this is profitable, it would be
> better to judge this patch (and maybe a testcase for the testsuite
> also).

OK, here's a test case.

void f (char *buf)
{
   __builtin_memcpy (buf, "foo", 3);
}

void g (char *buf)
{
   __builtin_memset (buf, 'f', 3);
}

The MIPS back end has its own custom block move expander, so HAVE_movmemsi is 
true, and the current behavior makes MOVE_RATIO default to 2.  But this only 
handles memcpy, not memset; so with -O2 we end up with f using the custom 
expansion and g using an out-of-line call.

The patch makes STORE_BY_PIECES_P zero so it will always go straight to the 
custom code for memcpy.  The SET_BY_PIECES_P test is now independent of 
MOVE_RATIO and HAVE_movmemsi, so with the patch can_store_by_pieces returns true 
for the memset and it uses the generic expansion instead of a library call.
Before:

g:
         .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
         .mask   0x00000000,0
         .fmask  0x00000000,0
         .set    noreorder
         .set    nomacro

         li      $5,102                  # 0x66
         li      $6,3                    # 0x3
         j       memset
         nop

With the patch:

g:
         .frame  $sp,0,$31               # vars= 0, regs= 0/0, args= 0, gp= 0
         .mask   0x00000000,0
         .fmask  0x00000000,0
         .set    noreorder
         .set    nomacro

         li      $2,102
         sb      $2,2($4)
         sb      $2,0($4)
         j       $31
         sb      $2,1($4)

The code for f, using the custom movmemsi expansion, is unchanged.

-Sandra

  parent reply	other threads:[~2007-08-15 19:58 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 [this message]
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
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=46C35A4B.1080105@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=davidu@mips.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=guym@mips.com \
    --cc=nigel@mips.com \
    --cc=pinskia@gmail.com \
    --cc=richard@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).