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.
Loop Code Optimization: Details
                                             Up Contents Index Back
─────C/C++ Compiler─────────────────────────────────────────────────────────
 
     Syntax:  /O[opt_code]
 
     These options affect the behavior of loop optimization:
 
     Option    Compiler Action
 
      /Ol      Causes the compiler to perform loop optimization by
               moving invariant code out of loops.
 
      /Oz      Enables maximum, and potentially unsafe, loop
               optimization.
 
      /On      Disables unsafe loop optimizations by preventing some
               constant expressions in a loop from being moved out.
               Since the /Ol option automatically implies /On, you do
               not need to specify /On explicitly; it is provided for
               compatibility with earlier versions of Microsoft C.
 
     The /Oz option aggressively removes as many invariant expressions
     as possible from a loop. If you do not specify /Oz, the /Ol
     option removes only the invariant expressions guaranteed to be
     executed in every iteration of the loop. Do not use /Oz if you
     suspect a loop optimization has caused an error.
 
     NOTES:
 
        ■ If /Ol is given with the /Os (Optimize for Size) option, the
          effect of /Ol takes precedence for loops.
 
        ■ If you specify /On without /Ol, /On has no effect. The /On
          option only works when it is specified with /Ol.
                                    -♦-