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: Help understanding tree-affine.c


Hello,

> I am trying to understand the usage of some functions in tree-affine.c
> file and I appreciate your help.
> 
> For example; for the two memory accesses
>  arr[b+8].X  and  arr[b+9].X, how does their affine combinations
> will look like after executing the following sequence of operation?
> (taken from http://gcc.gnu.org/ml/gcc-patches/2007-01/msg02605.html)
> 
> get_inner_reference_aff (mem1, &off1, &size1);
> get_inner_reference_aff (mem2, &off2, &size2);

off1 will be affine combination 1 * &arr + 8 * b + 64,
off2 will be 1 * &arr + 8 * b + 72 (assuming that size of the element of arr
is 8),

> aff_combination_expand (&off1, ttae_cache);
> aff_combination_expand (&off2, ttae_cache);

In these cases, off1 and off2 will be unchanged, since b is not defined
in terms of an affine expression.

> aff_combination_scale (&off1, double_int_minus_one);
> aff_combination_add (&off2, &off1);

This subtracts the two affine combinations, so off2 will be 8 in the
end.

> Also, why does diff->n is an indication for the fact that two memory
> accesses can overlap in the following snippet taken from the above link?

n is the number of terms of the affine combination, excluding the
constant offset.  For example, off1 above has n = 2, the terms of the affine
combination (&arr, b) and their coefficients (1, 8) are kept in the
elts array, the constant offset (64) is kept in the offset field.

So, if there is any non-constant term (i.e., n > 0), we cannot be sure
that the difference of the addresses is non-zero (actually, this could
be improved -- we could consider the value of the offset modulo the
greatest common divisor of the coefficients, and in some cases derive
that there cannot be an overlap).

Zdenek

> static bool
> cannot_overlap_p (aff_tree *diff, double_int size1, double_int size2)
> {
>   double_int d, bound;
> 
>   /* Unless the difference is a constant, we fail.  */
>   if (diff->n != 0)
>     return false;
> 
> Thanks in advance,
> Revital


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