/Ot   (Favor Fast Code)

OverviewHow Do ICompiler Options

Feature Only in Professional and Enterprise Editions   Code optimization is supported only in Visual C++ Professional and Enterprise Editions. For more information, see .

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.

To find this option in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click Optimizations in the Category box. Under Optimizations, click Customize.

x86 Specific

The following example code demonstrates the difference between the Favor Small Cod (/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).