public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Richard Guenther" <richard.guenther@gmail.com>
To: "Eric Botcazou" <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Tree SRA and atomicity/volatility
Date: Fri, 12 Jan 2007 17:03:00 -0000	[thread overview]
Message-ID: <84fc9c000701120903t6aa96ffp3d5e0520c57823f3@mail.gmail.com> (raw)
In-Reply-To: <84fc9c000701120836r5cfd514fqdfcbd7addccb2ec@mail.gmail.com>

On 1/12/07, Richard Guenther <richard.guenther@gmail.com> wrote:
> On 1/12/07, Eric Botcazou <ebotcazou@adacore.com> wrote:
> > [Sorry for the delay, pretty hot week]
> >
> > > On a second thought this cannot be true.  If you have "all the magic
> > > to support atomicity" and generate "the full-word access on" your own --
> > > why do you expose the individual fields to the middle-end at all??
> >
> > Well, the type has fields and you can access these fields individually in the
> > source so they must be present in the IL to generate debug info for them.
> >
> > > I claim you _cannot_ generate full-word access this way (unless
> > > using memcpy, but even that is nowadays lowered).
> >
> > Do not underestimate the cleverness of Gigi. :-)
>
> I don't see anything "clever" in
>
> Q ()
> {
>   typedef q__byte q__byte;
>   typedef struct q__word q__word;
>   struct q__word T1b = {.first=0, .second=0, .third=0, .fourth=0};
>   struct q__word tmp;
>   struct q__word external = VIEW_CONVERT_EXPR<struct q__word>(SAVE_EXPR <T1b>);
>
>   tmp = VIEW_CONVERT_EXPR<struct q__word>(external);
>   tmp.first = 0;
>   external = VIEW_CONVERT_EXPR<struct q__word>(tmp);
>   return;
> }
>
> for this testcase (t02.original dump, gcc 4.1.2) .  Now if I change the
> testcase to something I requested (direct write to a component), I get
>
> Q ()
> {
>   typedef q__byte q__byte;
>   typedef struct q__word q__word;
>   struct q__word T1b = {.first=0, .second=0, .third=0, .fourth=0};
>   struct q__word external = VIEW_CONVERT_EXPR<struct q__word>(SAVE_EXPR <T1b>);
>
>   VIEW_CONVERT_EXPR<struct q__word>(external).first = 0;
>   return;
> }
>
> and after gimplification we can see all it broken already (that is, you
> exposed the component write to the middle-end - no cleverness
> prevented this):
>
> Q ()
> {
>   struct q__word T1b.0;
>   typedef q__byte q__byte;
>   typedef struct q__word q__word;
>   struct q__word T1b;
>   struct q__word external;
>
>   T1b.first = 0;
>   T1b.second = 0;
>   T1b.third = 0;
>   T1b.fourth = 0;
>   T1b.0 = T1b;
>   external = T1b.0;
>   external.first = 0;
>   return;
> }
>
> The testcase now looks like:
>
> procedure Q is
>
>    type Byte is mod 2**8;
>    for Byte'Size use 8;
>
>    type Word is
>       record
>          First, Second, Third, Fourth : Byte;
>       end record;
>
>    External : Word := (others => 0);
>    pragma Atomic (External);
>
> begin
>    External.First := 0;
> end;
>

Oh, and of course wrong (?) assembly is created for this:

_ada_q:
.LFB3:
        pushl   %ebp
.LCFI0:
        movl    %esp, %ebp
.LCFI1:
        subl    $16, %esp
.LCFI2:
        movl    $0, -4(%ebp)
        movb    $0, -4(%ebp)
        leave
        ret

Richard.

  reply	other threads:[~2007-01-12 17:03 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-06 13:19 Eric Botcazou
2007-01-06 13:31 ` Richard Guenther
2007-01-06 13:47   ` Richard Kenner
2007-01-06 13:49   ` Eric Botcazou
2007-01-07 11:23     ` Richard Guenther
2007-01-08 11:30       ` Eric Botcazou
2007-01-08 11:52         ` Richard Guenther
2007-01-08 12:43           ` Eric Botcazou
2007-01-08 13:12           ` Richard Kenner
2007-01-08 13:40             ` Richard Guenther
2007-01-08 14:55           ` Richard Guenther
2007-01-12 13:57             ` Eric Botcazou
2007-01-12 16:36               ` Richard Guenther
2007-01-12 17:03                 ` Richard Guenther [this message]
2007-01-14  7:47                 ` Eric Botcazou
2007-01-14 14:57                   ` Richard Guenther
2007-01-19 13:58                     ` Eric Botcazou
2007-01-23 16:58 ` Mark Mitchell
2007-01-23 17:15   ` Daniel Berlin
2007-01-23 17:24   ` Richard Guenther
2007-01-23 19:38     ` Mark Mitchell
2007-01-23 20:57       ` Richard Guenther
2007-01-23 22:07         ` Mark Mitchell
2007-01-24  1:39           ` Richard Kenner
2007-01-24 13:33           ` Eric Botcazou
2007-01-24  1:31         ` Richard Kenner
2007-01-24  9:27           ` Richard Guenther
2007-01-24 13:02             ` Richard Kenner
2007-01-24 13:33               ` Richard Guenther
2007-01-24 13:57                 ` Richard Kenner
2007-01-24 18:31                 ` Mark Mitchell
2007-01-24 23:57                   ` Richard Kenner
2007-01-25  9:38                   ` Richard Guenther
2007-01-25 11:38                     ` Richard Kenner
2007-01-25 16:32                       ` Mark Mitchell
2007-01-25 16:41                         ` Richard Guenther
2007-01-25 18:29                           ` Richard Kenner
2007-01-25 22:03                       ` Mike Stump
2007-01-26  2:37                         ` Mark Mitchell
2007-01-26  2:44                           ` Mike Stump
2007-01-26  2:54                             ` Mark Mitchell
2007-01-26  9:17                               ` Richard Guenther
2007-01-26 10:12                                 ` Eric Botcazou
2007-01-26 13:40                                 ` Richard Kenner
2007-01-26 13:13                             ` Richard Kenner
2007-01-26 19:21                               ` Mike Stump
2007-01-24  0:53     ` Richard Kenner
2007-03-02 14:55 ` Eric Botcazou
2007-03-02 15:21   ` Diego Novillo

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=84fc9c000701120903t6aa96ffp3d5e0520c57823f3@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@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).