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: strict aliasing benefit examples


> base+offset really only helps in cases like:
> 
> int t[100];
> int t2[100];
> t[20] =1;
> t2[30] = 2;
> if (t[20] != 1)
>   abort ();

In the more general case, base plus offset helps in the Fortran style where
everything is done with arrays (Ada is like this too in typical usage).

So if you have

	for (i = 0; i < 100; i++)
	   for (j = 0; j < 100; j++)
	      arr1[j] = arr2[i] * arr3[j];

you can know that arr2[i] is an invariant in the inner loop even if all
arrays are arrays of ints (so alias analysis would be useless).

In my mind, I see the two techniques as complementary: there are some pairs
of references that can only be deconflicted using base+offset analysis and
some that can only be deconflicted using alias analysis.  The best compiler
will use both tools (plus some others).


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