This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Volatile MEMs in statement expressions and functions inlined as trees
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Linus Torvalds <torvalds at transmeta dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 06 Dec 2001 22:23:23 -0200
- Subject: Re: Volatile MEMs in statement expressions and functions inlined as trees
- Organization: GCC Team, Red Hat
- References: <200112062308.fB6N8un18531@penguin.transmeta.com>
On Dec 6, 2001, Linus Torvalds <torvalds@transmeta.com> wrote:
> In article <or4rn9fqka.fsf@free.redhat.lsd.ic.unicamp.br> you write:
>>
>> volatile int *p, *q, r;
>>
>> void foo() {
>> *p = *q = r; // don't load *p back
>> }
> Does this still load off "q"?
Yup. I'm pretty sure I read somewhere that this should be done, but I
can't find the reference now and, in fact, some reading of the C99 and
C++ Standards seem to imply that *q shouldn't be re-loaded.
> *q = r; // read 'r' just once, write to 'q'
> *p = *q; // read 'q' again, write it to 'p'
> (the latter seems to be what at least older versions of gcc reads into
> it).
Yup. Perhaps the `somewhere' where I read it was some GCC
documentation or source file :-(
[checks]
Yeah, I see this in expr.c:
/* If target is volatile, ANSI requires accessing the value
*from* the target, if it is accessed. So make that happen.
In no case return the target itself. */
if (! MEM_VOLATILE_P (target) && want_value)
dont_return_target = 1;
Do we want to change this? Perhaps some older C standard imposed this
requirement?
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me