To be more clear, I don't think this was caused by a code optimizer. I suspect it was a programmer's optimization at the source code level. In C, you can specify that a small number of variables can be kept in registers. Our optimizer would generally ignore these, because programmers were almost always wrong in their allocation of variables to registers. Furthermore, there was no good way to assign multiple variables to the same register because you would need some way to the live-dead analysis and even if you did, there was no practical syntax for telling the compiler about it. Much better to have the optimizer do it.But our optimizer build flow graphs of programs, did live-dead analysis of variables, etc., so we could tell much better than the programmer, who seldom had even profiled his program, and surely would not have the patience to do all the analysis our optimizer did. The acid test was always to take his code untouched by our optimizer and compare it to the code we optimized. They seldom believed the test results.The trouble with optimizing the code by hand is that is usually done locally, when it is the global optimizations that really matter. An increase in program and data locality will, on modern machines, improve execution speed much more than speeding up the loop in strcpy() function, for example.If you really want to optimize code, especially C code, by hand, read Jon Bentley's book on Writing Efficient Programs.
Best Of |
Favorites & Replies |
Start a New Board |
My Fool |
BATS data provided in real-time. NYSE, NASDAQ and NYSEMKT data delayed 15 minutes.
Real-Time prices provided by BATS. Market data provided by Interactive Data.
Company fundamental data provided by Morningstar. Earnings Estimates, Analyst Ra