public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Nathan Sidwell <nathan@codesourcery.com>
Cc: Richard Guenther <richard.guenther@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [gimple] assignments to volatile
Date: Tue, 22 Jun 2010 13:12:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1006221358360.11284@wotan.suse.de> (raw)
In-Reply-To: <4C209B90.6090703@codesourcery.com>

Hi,

On Tue, 22 Jun 2010, Nathan Sidwell wrote:

> IIUC, Michael's desired semantics are
> *) after an assignment, the value is re-read iff the assignment's value is
> used.
> *) a volatile object is not read in a void context.
> *) a volatile sub-expression is read or re-read if the value is used by the
> containing expression [I am unsure if this is Michael's semantics or not,
> please correct me if I'm wrong]

I think you're correct.

> I am unsure whether the behaviour Michael would like is dependent on
> optimization level.  I think that would be a very bad thing, btw.

It wouldn't be dependend on the optimization level, that would be 
terrible.  I.e. the "used-by" property would be purely syntactical.

> I think these lead to confusing code sequences, and are not composable.
> Fundamentally the ambiguity comes from specifying when an assignment's value
> is needed.

Indeed.  Both semantics (re-read or no re-read) will generate some 
surprises, mine has the problem of context dependency, yours for instance 
breaks this identity:
  x = vol = y;
<==>
  vol = y;
  x = vol;

I read the standard as requiring this identity to hold (in particular the 
language about values of assignments not being lvalues is only to disallow 
constructs like "(a = b) = c;").  That is my fundamental problem with your 
approach, that it effectively creates this identity:
  x = y    // as fragment
<==>
  (t = y, x = t, t)  // t a new temporary of the unqualified type of x

Note that I don't think this would be bad semantics, to the contrary (I'm 
not particularly glad about the context dependency that my reading 
implies).  I just don't see it justified in the standard.

> pattern of accesses to the volatile object.  (And by in my recent dive into
> gimplify, we'll have a harder patch to write as we need to track want_result
> through more structures than we do at the moment.)

I'd rather think that it's not gimplify's job at all to implement volatile 
semantics.  It's rather the frontend which should make sure all reads and 
writes to volatile objects are emitted as specified in the language 
standard.  gimplify then merely shouldn't change the number and kind of 
accesses to volatile objects (neither should any further transformation).

> Should whatever semantics we decide upon be implemented by the 
> gimplifier or by the front-end?  I'm not sure, but I do think the 
> gimplifier should specify the semantics of volatile accesses, and those 
> semantics should be consistent. Currently they are not.

I have no problem if we specify that we gimplify assignments as per the 
above second identity.  (I just also think that the C frontend needs 
fixing to emit explicit re-reads).


Ciao,
Michael.

  parent reply	other threads:[~2010-06-22 12:37 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-21 12:44 Nathan Sidwell
2010-06-21 13:26 ` Richard Guenther
2010-06-21 13:55   ` Michael Matz
2010-06-21 14:07     ` Richard Guenther
2010-06-21 14:09     ` Nathan Sidwell
2010-06-21 14:17       ` Michael Matz
2010-06-21 14:19         ` Richard Guenther
2010-06-21 14:53           ` Michael Matz
2010-06-21 14:17     ` IainS
2010-06-21 14:24       ` Michael Matz
2010-06-21 14:50         ` Nathan Sidwell
2010-06-21 15:24           ` Michael Matz
2010-06-22 11:36             ` Dave Korn
2010-06-23 20:16             ` Mike Stump
2010-06-24 11:51               ` Michael Matz
2010-06-21 15:24         ` Nathan Sidwell
2010-06-21 15:46           ` Michael Matz
2010-06-22 15:37     ` Mark Mitchell
2010-06-22 15:37       ` Jakub Jelinek
2010-06-22 15:57         ` Paul Koning
2010-06-22 15:47       ` Michael Matz
2010-06-22 15:58         ` Mark Mitchell
2010-06-23 11:38           ` Nathan Sidwell
2010-06-23 14:05             ` Mark Mitchell
2010-06-23 14:06               ` Michael Matz
2010-06-23 16:00                 ` Richard Guenther
2010-06-23 16:25               ` Paul Koning
2010-06-23 17:13                 ` Mark Mitchell
2010-06-23 19:16               ` Mike Stump
2010-06-24 10:22                 ` Mark Mitchell
2010-06-24 15:53                   ` Mike Stump
2010-06-24 16:00                     ` Mark Mitchell
2010-06-24 19:37                       ` Mike Stump
2010-06-25  9:37                         ` Nathan Sidwell
2010-06-25 19:06                           ` Mike Stump
2010-06-25 21:33                             ` Mark Mitchell
2010-06-26  9:35                               ` Mike Stump
2010-06-26 10:18                                 ` Mark Mitchell
2010-06-26 12:18                                   ` Richard Guenther
2010-06-26 19:52                                     ` Michael Matz
2010-06-26 19:57                                       ` Mark Mitchell
2010-06-26 20:08                                         ` Michael Matz
2010-06-26 22:13                                           ` Mark Mitchell
2010-06-28  9:20                                             ` Nathan Sidwell
2010-06-28  9:27                                               ` Nathan Sidwell
2010-06-26 10:20                                 ` Richard Kenner
2010-06-28  9:52                             ` Nathan Sidwell
2010-06-30 22:52                               ` Mike Stump
2010-07-05  8:59                                 ` Nathan Sidwell
2010-07-09  5:27                                   ` Mike Stump
2010-07-09  7:22                                     ` Nathan Sidwell
2010-07-16  8:10                                       ` Nathan Sidwell
2010-07-16 15:20                                         ` Mark Mitchell
2010-07-19  8:41                                           ` Nathan Sidwell
2010-08-13  9:56                                           ` Nathan Sidwell
2010-08-18 15:32                                             ` Mark Mitchell
2010-08-18 16:18                                               ` Richard Guenther
2010-08-18 18:04                                                 ` Mike Stump
2010-08-19 11:11                                               ` Nathan Sidwell
2010-08-20  4:22                                                 ` Mark Mitchell
2010-08-20 16:59                                                   ` Mike Stump
2010-08-20 18:00                                             ` H.J. Lu
2010-08-20 18:33                                               ` Nathan Sidwell
2010-06-25  9:20                       ` Nathan Sidwell
2010-06-24 10:23                 ` Nathan Sidwell
2010-06-24 17:05                   ` Mike Stump
2010-06-24 17:29                     ` Paul Koning
2010-06-25  9:26                     ` Nathan Sidwell
2010-06-25 18:20                       ` Mike Stump
2010-06-28  8:49                         ` Nathan Sidwell
2010-07-01  1:02                           ` Mike Stump
2010-07-05  9:02                             ` Nathan Sidwell
2010-07-09  5:14                               ` Mike Stump
2010-07-09  7:20                                 ` Nathan Sidwell
2010-06-22 15:56       ` Paul Koning
2010-06-22 12:08   ` Nathan Sidwell
2010-06-22 12:25     ` Richard Guenther
2010-06-22 13:12     ` Michael Matz [this message]
2010-06-22 13:54       ` Nathan Sidwell
2010-06-22 15:21         ` Michael Matz
2010-06-22 16:12           ` Joseph S. Myers

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=Pine.LNX.4.64.1006221358360.11284@wotan.suse.de \
    --to=matz@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nathan@codesourcery.com \
    --cc=richard.guenther@gmail.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).