This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Volatile MEMs in statement expressions and functions inlined as trees


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]