On 2006-03-17, David Brown <da...@westcontrol.com> wrote:

>> > * The avr-gcc people decided to use a __zero_reg__ (I don't
>> >   think it is an overall win), and put it in r0.  Since r0 is
>> >   unavoidably used by other features (multipliers, and LPM
>> >   instructions), it must be preserved in the interrupt
>> >   prologue, since the compiler code generator assumes it is
>> >   always valid.
>>
>> That doesn't make any sense.  The compiler is bright enough to
>> keep track of which "other" register get used and only preserve
>> the ones that are required, they must have added _extra_ code
>> to disable that for the zero reg.
>
> That's a little different.  When the compiler starts to
> produce a block of code, it assumes certain pre-conditions,
> and makes sure these are still valid at the end of the block.
> These include things like it being safe to use scratch
> registers, and unsafe to use preserved registers without
> actively preserving them.  The condition that __zero_reg__ is
> 0 and __tmp_reg__ is available happen at an even lower level -
> they are only broken over very short code sequences.  For
> example, __tmp_reg__ will never (as far as I know) be used for
> anything other than loading immediate values into the low
> numbered registers.  When compiling an interrupt function, the
> compiler must first establish these basic low-level
> conditions, and it seems to have no way to optomise them away.

There's no reason not to optimize that portion of the
prolog/epilog as well. It doesn't matter except for trivially
small ISRs. But, in may experience, some of them usually are --
and they're the ones that have to run the fastest.

-- 
Grant Edwards                   grante             Yow!  .. over in west
                                  at               Philadelphia a puppy is
                               visi.com            vomiting...


Reply via email to