Chapter 1 Optimizing Your Programs

The Microsoft C/C++ compiler translates C or C++ source statements into machine-executable instructions. In addition, the compiler rewrites or “optimizes” parts of your program to make it more efficient in ways that are not apparent at the source level.

The compiler performs three general types of optimization:

It modifies or moves sections of code so that fewer instructions are used, or so that the instructions used make more efficient use of the processor.

It moves code and combines operations to maximize use of registers because operations on data stored in processor registers are far faster than the same operations on data stored in memory.

It eliminates sections of code that are redundant or unused.

This chapter explains the various ways you can control how the Microsoft C/C++ compiler optimizes your code.