public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Guenther" <richard.guenther@gmail.com>
To: "Jakub Jelinek" <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Optimize var = STRING_CST
Date: Fri, 24 Aug 2007 09:59:00 -0000	[thread overview]
Message-ID: <84fc9c000708240237s7c1cd305g5c40b44a3a0f3484@mail.gmail.com> (raw)
In-Reply-To: <20070823212347.GC2063@devserv.devel.redhat.com>

On 8/23/07, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The following patch optimizes initialization of an array from a STRING_CST.
> Without this patch store_expr will always force the STRING_CST into memory
> and then do a block move from there, followed by optional clear_storage
> if the STRING_CST is shorter than the array.  This patch uses
> store_by_pieces if possible.
> With the patch:
> struct A { char c[10]; };
>
> void
> foo (void)
> {
>   struct A a = { "abcdefghi" };
>   baz (&a);
> }
>
> void
> bar (void)
> {
>   struct A a;
>   __builtin_strcpy (&a.c[0], "abcdefghi");
>   baz (&a);
> }
> both routines are the same on x86_64 except for
> slightly different register allocation, without that patch
> for foo a .LC0 constant with the string literal is emitted and foo
> copies over from that string into a.c array.
>
> Tested on x86_64-linux, ok for trunk?

This is ok if you add a testcase.  I also bet we have a PR  somewhere
for this one...

Thanks,
Richard.

> 2007-08-23  Jakub Jelinek  <jakub@redhat.com>
>
>         * expr.c (store_expr): Optimize initialization of an array
>         with STRING_CST.
>         * expr.h (builtin_strncpy_read_str): New prototype.
>         * builtins.c (builtin_strncpy_read_str): Remove prototype.
>         No longer static.

  reply	other threads:[~2007-08-24  9:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 23:48 Jakub Jelinek
2007-08-24  9:59 ` Richard Guenther [this message]
2007-08-24 13:42   ` Jakub Jelinek

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=84fc9c000708240237s7c1cd305g5c40b44a3a0f3484@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@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).