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]

Re: SSA usage question


>     These things can change from reference to reference?  That is,
>     given the array 'a' above, will every reference to 'a' use a
>     potentially different 'x' and 'v'?
>
> No.  They are the unchanging over the lifetime of an object.  If the
> type has placeholders, then it may be different between two objects of
> the same type, though.

Fortran does need to be able to change these values. Obviously they will only 
ever be changed when used via a pointer type.

For example:

program test
  real, target :: a(4)
  real, pointer :: x(:)

  a = (/11, 12, 13, 14/)
  x => a ! Point x at a
  print *, x(2) ! Expected output is "12"
  x => a(1::2) ! Point x at every other element of a
  print *, x(2) ! Expected output is "13"
end program

Will expand into something like:

void main()
{
  real[6] a;
  real[] *x_base;
  int x_lbound, x_stride;

  x_base = addr_expr<a>;
  x_lbound = 1;
  x_stride = 1; // Maybe (1 * sizeof(real))

  print (array_ref<indirect<a_base>, 2, x_lbound, x_stride>);

  x_base = addr_expr <a>;
  x_lbound = 1;
  x_stride = 2;

  print (array_ref<indirect<a_base>, 2, x_lbound, x_stride>);
}

Paul


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