Home | Overview | How Do I | Compiler Options
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.
The Optimizations (/O) options determine how the compiler fine-tunes the performance of your program. Four of the five optimization categories (Default, Disable (Debug), Maximize Speed, and Minimize Size) in the Optimizations drop-down list box require no further optimization on your part. If you select the fifth optimization category, Customize, you can set specific optimizations using the selections in the Optimizations list box.
Use /Od to disable optimization, speed compilation, and simplify debugging. Use /Og to enable fundamental global optimizations.
The following table summarizes the optimizations. Click a command name for more detail.
Command Line | Project Settings | Description |
/O1 | Minimize Size | Creates the smallest code in the majority of cases. |
/O2 | Maximize Speed | Creates the fastest code in the majority of cases. |
/Oa | Assume No Aliasing | Tells the compiler that your program does not use aliasing. An alias is a name that refers to a memory location that is already referred to by a different name. Using this option allows the compiler to apply optimizations it couldn’t otherwise use, such as storing variables in registers and performing loop optimizations. |
/Ow | Assume Aliasing Across Function Calls | Tells the compiler that no aliasing occurs within function bodies but might occur across function calls. After each function call, pointer variables must be reloaded from memory. |
/Ob | Inline Function Expansion | Controls which functions become expanded. Expanding a function inline makes the program faster because it does not incur the overhead of calling the function. |
/Og | Global Optimizations | Provides local and global optimizations, automatic-register allocation, and loop optimization. |
/Od | Disable (Debug) | Turns off all optimizations in the program and speeds compilation. This option simplifies debugging because it suppresses code movement. |
/Oi | Generate Intrinsic Functions | Replaces some function calls with intrinsic or otherwise special forms of the function that help your application run faster. Programs that use intrinsic functions are faster because they do not have the overhead of function calls, but may be larger because of the additional code created. |
/Op | Improve Float Consistency | Improves the consistency of floating-point tests for equality and inequality by disabling optimizations that could change the precision of floating-point calculations. |
/Os | Favor Small Code | Minimizes the size of .EXE files or 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 trade-offs of size versus speed. If you do not select this option, code may be larger and may be faster. |
/Ot | Favor Fast Code; Default | Maximizes the speed of .EXE files and DLLs by instructing the compiler to favor speed over size. 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. |
/Ox | Full Optimization | Combines optimizing options to produce the fastest possible program. |
/Oy | Frame-Pointer Omission | Suppresses creation of frame pointers on the call stack. This option speeds function calls, because no frame pointers need to be set up and removed. It also frees one more register, x86 Specific —>EBP on the Intel 386 (or later), END x86 Specific for storing frequently used variables and subexpressions. |
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.