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


On Dec 14, 2001, Linus Torvalds <torvalds@transmeta.com> wrote:

> 	t3 = a;			// reload 'a'
> 	t4 = c;			// load 'c'
> 	r2 = t3 + t4;		// rvalue of '(a += b) += c
> 	store r2 into a		// stable side effect of whole expression

> See? We end up reloading 'a' - simply because on the left side of the
> assignment we have to use the lvalue.

Interesting.  That's a very reasonable and consistent approach.  But
  ``The behavior of an expression of the form E1 op= E2 is equivalent
  to E1=E1 op E2 except that E1 is evaluated only once.'' [expr.ass]/7

seems to imply that:

                (a += b) += c;
                                   
should be equivalent to

                a = (a += b) + c;

but, according to my understanding of your interpretation, this
doesn't hold, because the latter would not load back from a after the
+= assignment, whereas the former would.

-- 
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


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