Hello,

> >Remarks:
> >-- it would be guaranteed that the indices of each memory reference are
> >   independent, i.e., that &ref[idx1][idx2] == &ref[idx1'][idx2'] only
> >   if idx1 == idx1' and idx2 = idx2'; this is important for dependency
> >   analysis (and for this reason we also need to remember the list of
> >   indices, rather than trying to reconstruct them from the address).
> 
> I didn't completely think through this,
> but how would this property help in the presence of array flattening ?
> e.g. suppose two adjacent loops, both two-nest-deep,
> and only one of them is flattened, then
> one loop will have one dimensional access (hence will have only one index)
> vs the other loop will have two dimensional.
> In other words, &ref[idx1] == &ref[idx1'][idx2'] can happen.

this cannot happen.  Suppose you have a declaration

int ref[100][100];

Then the first reference would be represented as
tmp = (int (*)[10000])) &ref;
tmp[idx1]

It cannot have ref as its base.

Similarly, if one wanted to implement the reverse transformation,
recovering multidimensional arrays from the flat representation,
he would have to transform

int a[10000];
for (i = 0; i < 100; i++)
  for (j =  0; j < 100; j++)
    a[100 * i + j] = ...

to

tmp = (int (*)[100][100]) &a;
for (i = 0; i < 100; i++)
  for (j =  0; j < 100; j++)
    ref with base: tmp, indices: (i,j) = ...

> Another question is, how would the representation look
> for more complicated address calculations
> e.g. a closed hashtable access like:
> 
> table[hash_value % hash_size]
> 
> and would it help in such cases ?

I am not quite sure what you ask for here; this would just be
represented as

idx = hash_value % hash_size;

and reference with base: table, indices: (idx)

Zdenek

Reply via email to