This is the mail archive of the 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 <> 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
Red Hat GCC Developer                  aoliva@{,}
CS PhD student at IC-Unicamp        oliva@{,}
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]