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

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

RE: [avr-gcc-list] Re: C vs. assembly performance


From: Weddington, Eric
Subject: RE: [avr-gcc-list] Re: C vs. assembly performance
Date: Sat, 28 Feb 2009 19:09:13 -0700

 

> -----Original Message-----
> From: 
> address@hidden 
> [mailto:address@hidden
> org] On Behalf Of Bob Paddock
> Sent: Saturday, February 28, 2009 6:40 PM
> To: address@hidden
> Subject: Re: [avr-gcc-list] Re: C vs. assembly performance
> 
> >  In practice, the experienced programmer can do a lot to help
> > the tools. avr-gcc *does* do a good job with most code - I do
> > much less re-structuring of my source code for avr-gcc than I do
> > for most other compilers (I use a lot of compilers for a 
> lot of >different targets).
> 
> Something I always found amusing/depressing is that some
> compilers generate smaller code for ++i than i++ everything
> being equal.  Then other compilers generate smaller code for i++ than
> ++i.  So in the embedded space you have to know what your tools are
> doing. Sadly it should not be this way.
> 
> avr-gcc generates the same size code in any case that I've looked at.
> 

Along the same lines of "you should know what your compiler generates" is the 
use of switch statements. They can be implemented (in the code generation) in 
many different ways, and it is based on heuristics. These heuristics are not 
always tuned the best way for the target.

So in application code I tend to avoid switch statements for embedded systems, 
unless I'm writing throw-away code or the application is trivial.




reply via email to

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