| www.delorie.com/gnu/docs/gcc/g77_19.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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. However, note that certain diagnostics--such as for uninitialized variables--depend on the flow analysis done by `-O', i.e. you must use `-O' or `-O2' to get such diagnostics.
The following flags have particular applicability when compiling Fortran programs:
-malign-double
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
See section 14.6.1 Aligned Data, for more information on alignment issues.
Also also note: The negative form of `-malign-double' is `-mno-align-double', not `-benign-double'.
-ffloat-store
This option is effective when the floating-point unit is set to work in IEEE 854 `extended precision'---as it typically is on x86 and m68k GNU systems--rather than IEEE 754 double precision. `-ffloat-store' tries to remove the extra precision by spilling data from floating-point registers into memory and this typically involves a big performance hit. However, it doesn't affect intermediate results, so that it is only partially effective. `Excess precision' is avoided in code like:
a = b + c d = a * e |
d = (b + c) * e |
For another, potentially better, way of controlling the precision, see 14.4.10 Floating-point precision.
-fforce-mem
-fforce-addr
-fno-inline
-ffast-math
-funsafe-math-optimizations
-fno-trapping-math
-fstrength-reduce
-frerun-cse-after-loop
-fexpensive-optimizations
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-fcaller-saves
-funroll-loops
DO loops by
unrolling them and is probably generally appropriate for Fortran, though
it is not turned on at any optimization level.
Note that outer loop unrolling isn't done specifically; decisions about
whether to unroll a loop are made on the basis of its instruction count.
Also, no `loop discovery'(1) is done, so only loops written with DO
benefit from loop optimizations, including--but not limited
to--unrolling. Loops written with IF and GOTO are not
currently recognized as such. This option unrolls only iterative
DO loops, not DO WHILE loops.
-funroll-all-loops
DO WHILE loops by
unrolling them in addition to iterative DO loops. In the absence
of DO WHILE, this option is equivalent to `-funroll-loops'
but possibly slower.
-fno-move-all-movables
-fno-reduce-all-givs
-fno-rerun-loop-opt
g77 based on gcc version 2.8.
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 (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 the GNU Compiler Collection (GCC), for more information on options to optimize the generated machine code.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |