avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Unused registers?


From: Ruud Vlaming
Subject: Re: [avr-gcc-list] Unused registers?
Date: Wed, 21 Oct 2009 12:48:24 +0200
User-agent: KMail/1.9.1

Hi Tomas,

In general it is very hard to force gcc to utilize all registers or particular
registers. And if you succeed, observe that in most of the times it 
results in extra mov's, so it does not tend to reduce code. One exception
is with framepointers. Gcc should avoid framepointers if you asked it
to do so (compileroption), and make use of the extra registers. 
Sometimes however it does not (i do not understand why), i.e.
sometimes gcc makes a framepointer for saving data instead
of utilizing unused registers. In that case you can try the following
trick. For example, to advise gcc to use register r6 for 'cVal':

  register volatile char cVal asm ("r6");

(Of course you can try that anyway, but i bet it will make code
not shorter in general). I am curious what results you obtain.

Having said that, i am sure there must be plenty of other
opportunities to reduce your code. I am still shaving of bytes
from my apps although i already thought they were a their
minimal size a year ago. I've become a real code reduction
expert by now. My motto is: "You can always take off 10%."
Thus, even if you already did so. ;-)

Ruud
http://www.femtoos.org/

On Wednesday 21 October 2009 10:59, Thomas Pircher wrote:
> Hi all,
> 
> I came across a strange behaviour of avr-gcc. In one of our programs (4k
> in Flash) the assembler code shows that the registers r2, r3, r5 and r6
> are not used at all. Since we are (as everyone, I guess) short in code
> space, I am wondering if there are some tricks that can make avr-gcc use
> those registers, too.
> 
> I'm not saying avr-gcc has a bug, as those registers are used when I
> compile other code.
> 
> Ideally, what I would like to know is if there is some special magic to
> make avr-gcc use all available registers and reduce the code size enough
> that we can squeeze in all the features asked for by marketing ;)
> 
> I'm using WinAVR 20071221 but 20090313 shows the same behaviour.
> 
> avr-size prog.elf
>    text    data     bss     dec     hex filename
>    4092       0      80    4172    104c prog.elf
> 
> Cheers,
> Thomas
> 
> 
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
> 




reply via email to

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