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: Linus Torvalds <torvalds at transmeta dot com>
- To: aoliva at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 6 Dec 2001 15:08:56 -0800
- Subject: Re: Volatile MEMs in statement expressions and functions inlined as trees
- Newsgroups: linux.egcs.patches
- Organization:
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"?
I don't think that's what an assignment operator implies.
An assignment operator will assign the value to the left side, and have
as its value the assigned value. NOT the "re-loaded value".
Which implies to me that
*p = *q = r;
really implies
tmp = r; // read 'r' just once
*q = tmp; // write it to q
*p = tmp; // write it to p
and NOT
*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).
Linus