This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH Re: [ast-optimizer-branch] gcc.dg/struct-alias-1.cfailure
>>>>> "Diego" == Diego Novillo <dnovillo@redhat.com> writes:
>> In the array simplification function, you made an effort to simplify the
>> bounds in left-to-right order. Why? It would seem more efficient to
>>
> To maintain current behaviour. While I think that there are no
> sequence points within an array expression (at least Annex C
> doesn't mention any), the following snippet of code will assign
> 26.02 to a[5][6][7]:
> a[i=5][j=i+1][k=j+1] = 26.02;
> If you were to simplify from right to left, you would get:
> k=j+1;
> j=i+1;
> i=5;
> a[i][j][k] = 26.02;
> which assigns to a random location of the array. It might well
> be that the code is undefined anyway, but I'd rather preserve
> current behaviour.
The order of evaluation is unspecified, just as it is in
f (i=5,j=i+1,k=j+1)
but in that case, evaluating from right to left has significant benefit for
targets that push their arguments; in the array case, the compiler should
be able to reorder code to get optimal results, so I suppose we might as
well conform to user expectations.
> Of course, we could have an additional argument to add_tree that
> tells it whether we want to add to the head or the tail of the
> list.
That could interfere with ordering of side-effects unrelated to the array
refs; however, building up a local list, nreversing it, and add_tree'ing it
all at once should work. Will do.
Jason