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

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

RE: [avr-gcc-list] foo++, subi vs inc?


From: Weddington, Eric
Subject: RE: [avr-gcc-list] foo++, subi vs inc?
Date: Tue, 11 Nov 2008 18:33:47 -0700

 

> -----Original Message-----
> From: 
> address@hidden 
> [mailto:address@hidden
> org] On Behalf Of Sparr
> Sent: Tuesday, November 11, 2008 5:53 PM
> To: address@hidden
> Subject: Re: [avr-gcc-list] foo++, subi vs inc?
> 
> On Tue, Nov 11, 2008 at 7:00 PM, Weddington, Eric
> <address@hidden> wrote:
> > What is the type of foo?
> 
> register unsigned char foo asm("r5");
> 
> On Tue, Nov 11, 2008 at 7:03 PM, Gre7g Luterman 
> <address@hidden> wrote:
> > Does it really matter which instruction the compiler chooses? Both
> > constructs consume the same amount of memory and execution time.
> >
> > I understand your concern that potentially more time and 
> memory could be
> > used if the compiler resisted the use of inc and the 
> register was below R16,
> > but unless you've seen evidence of it doing this... Is it 
> an issue or just
> > an idle curiousity?
> > Gre7g
> 
> It is an issue.  See above for the declaration of foo.  If r5 was used
> instead of copying to r21 it would save two instructions, which is not
> as trivial as it sounds since I am doing it inside a timer interrupt
> and my current goal is to shrink the code as much as possible.  I know
> I will eventually have to do optimizations in asm, but for now I'd
> like my C code to be compiled optimally.

If you want your C code to be compiled optimally, then don't reserve a specific 
register for a global variable. But then again, the AVR backend hasn't been 
tuned to generate optimal code either.

The issue could be very well in the AVR target machine description. You'll have 
to bite the bullet and go look at the code.




reply via email to

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