trouble with -fstrict-aliasing

Richard Guenther richard.guenther@gmail.com
Sat Jan 5 20:43:00 GMT 2008


On Jan 4, 2008 10:22 PM, Janus Weil <jaydub66@googlemail.com> wrote:
> Hi folks,
> I have some compile-time & memory-consumption issues here, when using
> the -fstrict-aliasing flag. What I'm doing is compile some 2000-line
> f90 file (which is actually part of a bigger program, and I haven't
> managed to produce a standalone test case yet), using a recent gcc
> trunk build. The problem is that with the higher optimization flags
> (-O2/-O3) compilation time really explodes:
>
> -O0: ~ 6 sec
> -O1: ~ 13 sec
> -O2: ~ 3 min (!)
> -O3: ~ 5 min (!)
>
> This is just no way reasonable for a single 2k-lines file, is it? I
> have compiled the same file before (with older gcc builds) without
> problems, so this problem must have been introduced recently
> (nov/dec?).
> It seems like one of the -O2 optimizations is to blame. So I looked a
> little closer, and found that -fstrict-aliasing seems to be the bad
> guy:
>
> -O1 -fstrict-aliasing:     ~ 2 min
> -O2 -fno-strict-aliasing: ~ 22 sec
> -O3 -fno-strict-aliasing: ~ 30 sec
>
> As long as I avoid -fstrict-aliasing everything is fine, but when I
> enable it, compilation becomes really sluggish. And also memory
> consumption seems to rise sharply. On an old machine with just 256MB
> of memory, compilation with -O3 fails due to lack of memory.
>
> I have trouble isolating a test case because I don't really know what
> -fstrict-aliasing does, in particular I'm not sure what kind of
> fortran code is affected by this option. In the manual there were only
> C examples, but it seems like it only affects pointers, and I'm pretty
> sure that there are no pointers used in my source file.
>
> Can anyone give me a hint on what direction to look in, and what kind
> of fortran code could be affected by -fstrict-aliasing?

In general I have seen memory and compile-time issues with lots
of fortran I/O in a single function (because gfortran allocates a new
I/O stat structure per I/O statement).  But I would suggest to put the
whole thing as a testcase in a bugzilla PR.

Richard.



More information about the Fortran mailing list