In addition to the default optimizations, the Microsoft C/C++ compiler also automatically uses the /Ot option, which optimizes for speed. The /Ot option enables optimizations that increase speed but may also increase size. If you would rather optimize for program size, use the /Os option. The /Os option enables optimizations that decrease program size but may also decrease program speed.
To optimize for speed or size on a per-function basis, use the optimize pragma with the t option. The on setting instructs the compiler to optimize for speed; the off setting instructs the compiler to optimize for compactness of code. For example,
#pragma optimize( “t”, off ) /* Optimize for smallest
code. */
.
.
.
#pragma optimize( “t”, on ) /* Optimize for fastest
code. */
The /Os option is implied when you use the /Oq option (p-code generation).