Enabling Common Subexpression Optimization (/Oc and /Og)

When you use option /Og (enable global common subexpression optimizations), the compiler searches entire functions for common subexpressions. Option /Oc (default common subexpression optimization) examines only short sections of code for common subexpressions. You can disable default common subexpression optimization with the /Od option. For more information about common subexpression optimization, see “Default Optimization”.

This option is not available if you use the /Oq option (p-code generation).

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.

Calling the setjmp or longjmp functions when global commmon subexpression optimization is in effect can cause the compiler to generate incorrect code. Use the optimize pragma with the g option to disable this optimization in functions that call setjmp and longjmp.