[Top][All Lists]

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

Re: [avr-gcc-list] code optimisation

From: Geoffrey Wossum
Subject: Re: [avr-gcc-list] code optimisation
Date: Wed, 18 Aug 2004 10:07:06 -0500
User-agent: KMail/1.6.2

On Wednesday 18 August 2004 9:39 am, Graham Davies wrote:
> I think Dave could be right that optimization should not be an early
> concern, if ever.  However, those guys he quoted were not from the embedded
> world and sometimes things can be different down here.

The AVR architecture is much faster than you'd (well, I'd) expect from an 
8-bit MCU.  gcc also seems to do a good job optimizing for it.  Very rarely 
have I had to optimize code I have written for an AVR.  When I do, the stuff 
I do isn't AVR or gcc specific.  It's standard optimization stuff like 
hoisting invariants out of loop bodies, amortizing calculations, use lookup 
tables, etc.  Stuff that you could do on any architecture with any compiler.

That being said, although I never do anything special for speed, I do jump 
through some hoops to keep my memory usage (both RAM and flash) down.  
However, once again, the memory optimization I do isn't AVR or gcc specific.

> I'm wondering if Trevor is coming at AVR GCC from a compiler that has a
> lousy built-in code optimizer?  I have used ZiLOG's ZDS II for the Z8
> Encore, which is a good example of this.  By inspecting the generated code
> I was able to figure out all kinds of dumb tricks to reduce the size and
> increase the speed. 

Similar situation with cc65 (a free 6502 compiler).  cc65 actually does an 
excellent job of optimizing code, considering how unkind the 6502 
architecture is to high-level languages.  But I've still had to figure out 
all kinds of odd tricks to speed up the code it generated in order to get the 
performance I needed from the code.  My experience is that writing odd 
looking code to try to get extra performance out of most "modern" compilers 
(gcc, MSVC, ICC) is ranges from having no effect, to actually producing worse 

Geoffrey Wossum
Software Engineer
Long Range Systems - http://www.pager.net

reply via email to

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