Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Problems with "ANSI aliasing" [was: Why C is much slower ..]

From: zal...@netcom.com (Zalman Stern)
Subject: Re: Problems with "ANSI aliasing" [was: Why C is much slower ..]
Date: 1999/05/07
Message-ID: <99-05-019@comp.compilers>#1/1
X-Deja-AN: 475041449
Approved: compil...@iecc.com
Sender: jo...@iecc.com
References: <3710584B.1C0F05F5@hotmail.com>  <7etenl$nk5$1@alexander.INS.CWRU.Edu> <99-04-048@comp.compilers>  <99-04-105@comp.compilers> <99-04-110@comp.compilers> <99-05-006@comp.compilers>
X-submission-address: compil...@iecc.com
X-moderator-address: compilers-requ...@iecc.com
Followup-To: comp.lang.c++,comp.lang.fortran,comp.compilers
Organization: Netcom
Keywords: C, Fortran, optimize
Newsgroups: comp.lang.c++,comp.lang.fortran,comp.compilers
X-FAQ-and-archives: http://www.iecc.com/compilers

bg...@my-dejanews.com wrote:
: t...@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-