Compiler Optimization

Link to Compiler Optimization article on MSDN

This article is about Visual C++ compiler optimizations. I’m going to discuss the most important optimization techniques and the decisions a compiler has to make in order to apply them. The purpose isn’t to tell you how to manually optimize the code, but to show you why you can trust the compiler to optimize the code on your behalf. This article is by no means a complete examination of the optimizations performed by the Visual C++ compiler. However, it demonstrates the optimizations you really want to know about and how to communicate with the compiler to apply them.

There are other important optimizations that are currently beyond the capabilities of any compiler—for example, replacing an inefficient algorithm with an efficient one, or changing the layout of a data structure to improve its locality. However, such optimizations are outside the scope of this article.