/Os, /Ot (Favor Small Code, Favor Fast Code)

/Os (Favor Small Code) minimizes the size of EXEs and DLLs by instructing the compiler to favor size over speed. The compiler can reduce many C and C++ constructs to functionally similar sequences of machine code. Occasionally these differences offer tradeoffs of size versus speed. The /Os and /Ot options allow you to specify a preference for one over the other:

/Ot (Favor Fast Code) maximizes the speed of EXEs and DLLs by instructing the compiler to favor speed over size. (This is the default.) The compiler can reduce many C and C++ constructs to functionally similar sequences of machine code. Occasionally, these differences offer tradeoffs of size versus speed. The /Ot option is implied by the Maximize Speed (/O2/O1, /O2 (Minimize Size, Maximize Speed)) option. The /O2 option combines several options to produce very fast code.

/* differ.c
This program implements a multiplication operator
Compile with /Os to implement multiply explicitly as multiply.
Compile with /Ot to implement as a series of shift and LEA instructions.
*/
int differ(int x)
{
return x * 71;
}

As shown in the fragment of machine code below, when DIFFER.c is compiled for size (/Os), the compiler implements the multiply expression in the return statement explicitly as a multiply to produce a short but slower sequence of code:

Alternately, when DIFFER.c is compiled for speed (/Ot), the compiler implements the multiply expression in the return statement as a series of shift and LEA instructions to produce a fast but longer sequence of code: