On Fri, Dec 2, 2011 at 1:14 PM, Peter Bigot <big...@acm.org> wrote:
> 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.

It's ok in terms of GCC internals.  Whether it's ok in terms
of the C language specification I don't know (but I think it is ok).
Whether it is desirable is another question - and whether such
desired behavior is easy to implement is another one.

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

Yes, I think it is valid.

Richard.

> Peter

Reply via email to