From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oskar Enoksson To: Jim Wilson Cc: egcs@cygnus.com Subject: Re: Optimization Date: Thu, 02 Apr 1998 03:41:00 -0000 Message-id: References: <199804010148.RAA14429@rtl.cygnus.com> X-SW-Source: 1998-04/msg00037.html On Tue, 31 Mar 1998, Jim Wilson wrote: > for (i=0; i<100; i++) > for (j=0; j<100; j++) > for (k=0; k<100; k++) > *(x+i*step[2]+j*step[1]+k*step[0]) *= > *(x+i*step[2]+j*step[1]+k*step[0]); > > This is a hard problem. We can't move the loads from step[] outside > the loop unless we can know for sure that the stores into *(x+...) won't > modify any of the values pointed to by step. Since we have no info about > where x or step point to, we make the worst case assumption that they > overlap, and hence the loads from step[] are not loop invariant. Of cource I have no idea how complicated this would be ... but it sure would be nice to have something like the following flags: -fno-alias Compiler assumes that no aliases exist. -fno-typed-alias Compiler assumes that different types cannot be aliased. -fno-float-alias Compiler assumes that float/double types don't alias with other types. -fno-pointer-alias Compiler assumes that pointer types cannot be aliased with non-pointer types. Am I dreaming? ;-) I think SGI has something like the first two compiler options. The KAI C++ compiler has --abstract-float and --abstract-pointer flags similair to the third and fourth option above. > It is actually a bit more complicated than that (we have type info to help > with aliasing), but it is still a complicated problem. > > The ISO C9X restrict keyword would make this optimization easier, because > this would allow the programmer to tell the compiler that there is no aliasing. Yes, that would be nice to, and perhaps easier to implement? Regards. /Oskar