Go to the first, previous, next, last section, table of contents.


Options That Control Optimization

Most Fortran users will want to use no optimization when developing and testing programs, and use `-O' or `-O2' when compiling programs for late-cycle testing and for production use.

The following flags have particular applicability when compiling Fortran programs:

-malign-double
(Intel 386 architecture only.) Noticeably improves performance of g77 programs making heavy use of REAL(KIND=2) (DOUBLE PRECISION) data on some systems. In particular, systems using Pentium, Pentium Pro, 586, and 686 implementations of the i386 architecture execute programs faster when REAL(KIND=2) (DOUBLE PRECISION) data are aligned on 64-bit boundaries in memory. This option can, at least, make benchmark results more consistent across various system configurations, versions of the program, and data sets. Note: The warning in the gcc documentation about this option does not apply, generally speaking, to Fortran code compiled by g77. Also note: g77 fixes a gcc backend bug to allow `-malign-double' to work generally, not just with statically-allocated data. Also also note: The negative form of `-malign-double' is `-mno-align-double', not `-benign-double'.
-ffloat-store
Might help a Fortran program that depends on exact IEEE conformance on some machines, but might slow down a program that doesn't.
-fforce-mem
-fforce-addr
Might improve optimization of loops.
-fno-inline
Don't compile statement functions inline. Might reduce the size of a program unit--which might be at expense of some speed (though it should compile faster). Note that if you are not optimizing, no functions can be expanded inline.
-ffast-math
Might allow some programs designed to not be too dependent on IEEE behavior for floating-point to run faster, or die trying.
-fstrength-reduce
Might make some loops run faster.
-frerun-cse-after-loop
-fexpensive-optimizations
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-fcaller-saves
Might improve performance on some code.
-funroll-loops
Definitely improves performance on some code.
-funroll-all-loops
Definitely improves performance on some code.
-fno-move-all-movables
-fno-reduce-all-givs
-fno-rerun-loop-opt
Each of these might improve performance on some code. Analysis of Fortran code optimization and the resulting optimizations triggered by the above options were contributed by Toon Moene (@email{toon@moene.indiv.nluug.nl}). These three options are intended to be removed someday, once they have helped determine the efficacy of various approaches to improving the performance of Fortran code. Please let us know how use of these options affects the performance of your production code. We're particularly interested in code that runs faster when these options are disabled, and in non-Fortran code that benefits when they are enabled via the above gcc command-line options.

See section `Options That Control Optimization' in Using and Porting GNU CC, for more information on options to optimize the generated machine code.


Go to the first, previous, next, last section, table of contents.