This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Complex overlaping expressions.


I'm currently seeing failures in certain fortran 95 programs which use 
complex numbers. GCC doesn't seem to be correctly handling complex 
expressions with overlapping source and destination.

Ie. expressions of the form A = A * B, where A and B are complex.

What seems to be happening is that the real component of A is overwritten 
before the complex component of A*B is calculated.

When I write an equivalent C program, the .t05.gimple tree dump shows a 
temporary has been inserted. I.e. the above has been transformed to 
tmp = A; A = tmp * B;

With gfortran this doesn't seem to be happening. Am I missing something, or 
is this a bug in the gimplifier/optimizers? I remember seeing various bits 
of code in g77 to deal with this, so maybe it's not a new thing.

Simple cases (like the one above) seem to work ok, probably by chance. 
However we sometimes generate code of the form
complex z, a;
for (i = 1; i < n; i++)
	z = z * a;

Where both z and a are compiler generated temporary variables. This results 
in broken code as described above.

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]