Related articles |
---|
Re: Why C is much slower than Fortran sokal@holyrood.ed.ac.uk (Daniel Barker) (1999-04-18) |
Re: Why C is much slower than Fortran telken@sgi.com (Thomas Elken) (1999-04-29) |
Problems with "ANSI aliasing" [was: Why C is much slower ..] trt@cs.duke.edu (1999-04-30) |
Re: Problems with "ANSI aliasing" [was: Why C is much slower ..] bglbv@my-dejanews.com (1999-05-03) |
Re: Problems with "ANSI aliasing" [was: Why C is much slower ..] zalman@netcom.com (1999-05-07) |
From: | zalman@netcom.com (Zalman Stern) |
Newsgroups: | comp.lang.c++,comp.lang.fortran,comp.compilers |
Followup-To: | comp.lang.c++,comp.lang.fortran,comp.compilers |
Date: | 7 May 1999 01:13:09 -0400 |
Organization: | Netcom |
References: | <3710584B.1C0F05F5@hotmail.com> <7etenl$nk5$1@alexander.INS.CWRU.Edu> 99-04-048 99-04-105 99-04-110 99-05-006 |
Keywords: | C, Fortran, optimize |
bglbv@my-dejanews.com wrote:
: trt@cs.duke.edu (Thomas R. Truscott) writes:
: > Also, a pointer cast to another type should not be assumed
: > to be distinct from the original pointer.
: You are missing the point. If the code you are compiling relies on
: pointer type casts, then -OPT:alias=typed is unsafe. Of course there
: is C code out there for which this option is unsafe; that is why it
: isn't turned on by default!
Consider the following:
contrived_example(int *foo, float *bar, int count) {
float sum = 0;
void *temp = (void *)foo;
/* Suspend disbelief on this untyped interface for a moment... */
generate_random_permutation(temp, sizeof(int), count);
/* We want to schedule this loop knowing that foo and bar do not
* alias.
*/
while (count-- > 0) {
sum += bar[*foo];
*foo++ = 0;
}
}
If type based aliasing works the way restrict does, the compiler is
required to notice that temp aliases with foo in the above
example. (And hence cannot hoist loads from foo above the call to
generate_random_permutation .) The type based aliasing information is
used for initializing the interference information at the function
start.
(Yes, I know the above is bad code. That isn't the point...)
-Z-
Return to the
comp.compilers page.
Search the
comp.compilers archives again.