On Fri, Dec 2, 2011 at 5:46 AM, <paul_kon...@dell.com> wrote: > > ... > >> It's never correct to exchange volatile accesses. > > > >That's not true. volatile accesses to different memory locations > >have no special dependence. If it happens that GCC doesn't > >do this kind of things then this is only because most passes > >don't thouch volatile stmts at all (thus the reports for sub-optimal > >code with volatile - we don't even try to do legal transformations). > > I'm confused. Do you mean that in > Volatile int *a, *b; > Int j, k; > J = *a; k = *b; > it is ok to fetch *b before *a? I can't think of any device driver writer > who would expect that.
While I don't have the reproducing case to hand, I did find a situation where something like: volatile unsigned int counter; // tied to system clock volatile unsigned int ioport; t0 = counter; // stuff with ioport t1 = counter; ended up being: //stuff with ioport t0 = counter; t1 = counter; This might have been due to misbehavior of a machine role in my target, but at the time I convinced myself that technically the move was legal even though it completely invalidated the timing I was trying to do. Peter