------- Comment #7 from kargl at gcc dot gnu dot org 2009-07-16 22:47 ------- Further investigation suggests that -O3 is unusable with Fortran code when the size of the code in a single file or module becomes very large. Specifically, gcc.info states:
'-O3' turns on all optimizations specified by '-O2' and also turns on the '-finline-functions', '-funswitch-loops', '-fpredictive-commoning', '-fgcse-after-reload' and '-ftree-vectorize' options. On my system with OPT="-O2 -pipe -march=native", I get % time gfc4x -c $OPT shift_domain_em.f90 292.91 real 270.35 user 20.92 sys % time gfc4x -c $OPT -finline-functions shift_domain_em.f90 297.52 real 275.26 user 21.39 sys % time gfc4x -c $OPT -fpredictive-commoning shift_domain_em.f90 294.75 real 271.22 user 21.21 sys % time gfc4x -c $OPT -fgcse-after-reload shift_domain_em.f90 295.13 real 270.59 user 21.51 sys % time gfc4x -c $OPT -funswitch-loops shift_domain_em.f90 630.73 real 601.11 user 24.99 sys % time gfc4x -c $OPT -ftree-vectorize shift_domain_em.f90 880.61 real 610.32 user 56.16 sys It is also noteworthy that the first 5 command lines require about 2 GB of memory to compile the code. The last command line required more than 6 GB of memory, and on my system this leads to swapping. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40773