[gfortran] Complex type components

Paul Brook paul@nowt.org
Wed Sep 10 00:09:00 GMT 2003


On Wednesday 10 September 2003 12:50 am, Gabriel Dos Reis wrote:
> Paul Brook <paul@nowt.org> writes:
> | We currently get gimplification failures when taking the real or
> | imaginary part of a comples expression. Example:
> | {
> |   complex z;
> |   double r;
> |   r = __real__ (z*z)
> | }
> |
> | The patch below makes the gimplifier mandle these like component
> | references, rather than array refs.
>
> please could you elaborate on the actual optimisation wins?  I would
> think that an array ref would give a better non-aliasing attribute.

The difference is whether we require an lvalue, or accept rvalues when 
gimplifying. I don't know how all the aliasing stuff works, but a component 
ref would seem to be a closer match than an array ref.

> | I'm not sure if this was originally an oversight or
> | a deliberate decision - they aren't part of the original SIMPLE
> | grammar.
> |
> | As a related change it also allow REALPART_EXPR and IMAGPART_EXPR as
> | operands of an ADDR_EXPR. Without this &__real__ z would silently
> | gimplify to the address of a temporary, not the component of the
> | complex value.
>
> Hmm, why would a temporary would be needed if the ref were a array ref?

They aren't array refs, we just apply the same rules when gimplifying.
The problem is that we allow complex component refs when gimplifying 
compound lvalues, but then reject them when testing if the result is an 
lvalue. In some cases this causes unwanted temporaries, in others an ICE.

Paul



More information about the Gcc-patches mailing list