C/C++ Compiler (cl.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Enable Common Subexpression Optimization (/Oc, /Og)
◄Up► ◄Contents► ◄Index► ◄Back►
─────C/C++ Compiler─────────────────────────────────────────────────────────
Syntax: /Oc
/Og
Use of either the /Oc or the /Og option allows the compiler to
calculate the value of a common subexpression once. For example,
"b + c" is common to the following code. If the values of b and c
do not change between the three expressions, the compiler can
calculate the value of b + c once, assign the calculation to a
temporary variable, and substitute the variable as appropriate.
a = b + c;
d = b + c;
e = b + c;
When you use the /Oc option (default common subexpression
optimization) the compiler examines short sections of code (basic
blocks) for common subexpressions. When you use the /Og option
(enable global common subexpression optimization) the compiler
searches entire functions for common subexpressions. You can
disable the default common subexpression optimization with the /Od
option.
NOTE: You can enable or disable block-scope common subexpression
optimization on a function-by-function basis using the
optimize pragma with the c option. You can enable or disable
global common subexpression optimization on a function-by-
function basis using the optimize pragma with the g option.
-♦-