Message Font: Serif | Sans-Serif
No. of Recommendations: 1
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.
Print the post  


When Life Gives You Lemons
We all have had hardships and made poor decisions. The important thing is how we respond and grow. Read the story of a Fool who started from nothing, and looks to gain everything.
Contact Us
Contact Customer Service and other Fool departments here.
Work for Fools?
Winner of the Washingtonian great places to work, and Glassdoor #1 Company to Work For 2015! Have access to all of TMF's online and email products for FREE, and be paid for your contributions to TMF! Click the link and start your Fool career.