Syntax:
The /optimize option controls the level of optimization performed by the compiler. To provide efficient run-time performance, Visual Fortran increases compile time in favor of decreasing run time. If an operation can be performed, eliminated, or simplified at compile time, the compiler does so rather than have it done at run time. Also, the size of object file usually increases when certain optimizations occur (such as with more loop unrolling and more inlined procedures).
In the visual development environment, specify the Optimization Level in the General or Optimizations Compiler Option Category. The /optimize options are:
/optimize:0 or /Od | /optimize:1 |
/optimize:2 | /optimize:3 |
/optimize:4, /Ox, and /Oxp | /optimize:5 |
The /optimize options:
Disables nearly all optimizations. This is the default if you specify /debug (with no keyword). Specifying this option causes certain /warn options to be ignored. The /optimize:0 option is the default in the the visual development environment for a debug configuration. Specifying /Od sets the /optimize:0 and /math_library:check options.
Enables local optimizations within the source program unit, recognition of common subexpressions, and expansion of integer multiplication and division (using shifts).
Enables global optimization. This includes data-flow analysis, code motion, strength reduction and test replacement, split-lifetime analysis, and instruction scheduling. Specifying /optimize:2 includes the optimizations performed by /optimize:1.
Enables additional global optimizations that improve speed (at the cost of extra code size). These optimizations include:
Enables interprocedure analysis and automatic inlining of small procedures (with heuristics limiting the amount of extra code). Specifying /optimize:4 includes the optimizations performed by /optimize:1 /optimize:2, and /optimize:3. For the DF command, /optimize:4 is the default for the command line unless you specify /debug (with no keyword). In the the visual development environment for a release configuration, the default is /optimize:4.
Specifying /Ox sets: /optimize:4, /math_library:fast, and /assume:nodummy_aliases.
Specifying /Oxp sets: /optimize:4, /math_library:check, /assume:nodummy_aliases, and /fltconsistency.
On ia32 systems, activates the loop transformation optimizations (also set by /transform_loops). On ia64 systems, activates the loop transformation optimizations (also set by /transform_loops) and the software pipelining optimization (also set by /pipeline (ia64 only)):
Loop transformation optimizations include loop blocking, loop distribution, loop fusion, loop interchange, loop scalar replacement, and outer loop unrolling. You can specify loop transformation optimizations without software pipelining (see /[no]transform_loops).
You can specify software pipelining without loop transformation optimizations (see /[no]pipeline (ia64 only)).
To determine whether using /optimize:5 benefits your particular program, you should compare program execution timings for the same program (or subprogram) compiled at levels /optimize:4 and /optimize:5.
Specifying /optimize:5 includes the optimizations performed by /optimize:1, /optimize:2, /optimize:3, and /optimize:4.
For detailed information on these optimizations, see Optimization Levels: the /optimize Option.
For information about timing your program, see Analyze Program Performance.
To compile your application for efficient run-time performance, see Compile With Appropriate Options and Multiple Source Files.