Feature Only in Professional and Enterprise Editions Code optimization is supported only in Visual C++ Professional and Enterprise Editions. For more information, see Visual C++ Editions.
/Ot
This option maximizes the speed of .exe files 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 trade-offs of size versus speed.
x86 Specific
The following example code demonstrates the difference between the Favor Small Code (/Os) options and the Favor Fast Code (/Ot) option:
/* 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:
mov eax, DWORD PTR _x$[ebp] imul eax, 71 ; 00000047H
Alternatively, 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:
mov eax, DWORD PTR _x$[ebp] mov ecx, eax shl eax, 3 lea eax, DWORD PTR [eax+eax*8] sub eax, ecx
END x86 Specific
Note The /Ot option is implied by the Maximize Speed (/O2) option. The /O2 option combines several options to produce very fast code. The /Os and /Ot options have their greatest effect when used with Global Optimizations (/Og).
/O options (Optimize Code) | Compiler Options | Setting Compiler Options