http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55585
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-04 11:00:39 UTC --- (In reply to comment #4) > Interestingly, the magic switch is -fstrict-aliasing... 20x speedup. for a > Fortran code quite a surprise. > > > time gfortran -c -O1 -fbounds-check -g -fstrict-aliasing slow.f90 > real 0m11.483s > > I think for Fortran -fstrict-aliasing could well be the default at -O1, but > maybe there is an underlying reason why this flag is needed ? Well, it probably enables CSE that removes some of the bounds-checking calls. Not sure why exactly without investigating. GFortran could enable strict-aliasing unconditionally if it likes (even at -O0).