avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] Missed Optimisation ?


From: Graham Davies
Subject: Re: [avr-chat] Missed Optimisation ?
Date: Tue, 01 Mar 2011 13:08:51 -0500

Michael Hennebry wrote:

We haven't been told how or if "result" is defined.

Yes, we have.

ISRs can be called like ordinary functions.

Only if you're nuts, but it's irrelevant, anyway.

The compiler could know [whether Bob is right or wrong to
declare 'result' volatile].  If the definition is in the same file
as the ISR, the compiler could know that "result" need not
be volatile, though not in this case.

This is completely wrong-headed.  The whole point of volatile is to tell the
compiler something about a variable that it cannot see in the source code of
the translation unit.

In this case, if the definition is in the same file as the ISR,
the compiler would know that "result" is in internal SRAM.

No, it wouldn't.  The C language supports only a single address space and
assumes that all variables that are not declared or are implicitly automatic
are in "memory".  We have to jump through hoops to make the C language work
with the Harvard architecture of many microcontrollers.  This does not
further the discussion.

From this, the compiler could correctly conclude that
neither fetches nor stores have side-effects.

No, it can't.  Or, it isn't useful to conclude that there are not side
effects because there are other reasons to use the storage qualifier
volatile that require the same behavior from the compiler.

Graham.

P.S.  This is now getting ridiculous, so I'm going to try to end my
involvement with this thread of discussion.  In parting I would just like to
caution anyone who is trying to learn anything that there has been a lot of
rubbish posted in this thread so it would be better to go elsewhere.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]