[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] code optimisation
From: |
Dave Hansen |
Subject: |
RE: [avr-gcc-list] code optimisation |
Date: |
Tue, 17 Aug 2004 18:23:06 -0400 |
From: Trevor White <address@hidden>
Hi all.
I am looking to find out how to write code that gcc prefers w.r.t.
optimisation. Where can I find out information on what gcc prefers to what
it does not?
Experimentation.
while (!satisfied)
{
write_some_code();
compile();
examine_generated_code();
}
Note that results may change with different versions of the same compiler...
However, C. A. R. Hoare said "Premature Optimization is the root of all
evil." D. Knuth agrred. M. A. Jackson gave the following two rules for
optimization:
1) Don't do it.
2) (For experts only) Don't do it yet.
My own rules (which aren't entirely orignal) are:
1) First make it right.
2) Then make it fast (or small). But only if you _need_ to.
3) Selecting a better algorithm and/or data structure will produce more
dramatic results than stupid coding tricks.
Regards,
-=Dave
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/