🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #53169

Noalias??

#53169
From: Matt Kennel
Date: Sun, 01 Mar 1992 00:53
51 lines
1982 bytes
Does gcc 2.0 have any sort of "noalias" provision?  Or can it automatically
assume such a thing in some cases?


Background from a non computer-scientist:

As far as I know a "noalias" facility is usually useful for numerical codes:


Consider:

void affine_transformation(int N, double *A, double B, double *C, double *X)
{
	/* implement vector operation:  X= A + B * C
	int i;

	for (i=1; i <= N; i++) {

		X[i] = A[i] + B * C[i];

	}
	
}


The problem comes about, because as arrays are passed as pointers in C,
the   X[i] may happen to lie at the same address as A[j], or something
like that.  As C is defined in terms of a serial model of execution, the
compiler has to follow the steps explicitly.

Of course, in most code, this never happens.  But because it's legal
in C, it can inhibit optimization.  A "noalias" facility allows one
to somehow let the compiler know that this isn't a possiblity.

FORTRAN, for example, disallows this aliasing by assumption
(it will generate "wrong" results if they arguments overlap) , and so
can still generate better code than C compilers for situations like
these.


Specifically, I have some hand-translated C versions of LINPACK routines.

I think they run slower than FORTRAN for this reason.  However, if I could
specify noalias, and declare vector routines "inline" (I actually do
this already) things might be better.



Matt Kennel
mbk@inls1.ucsd.edu
Technical Details
Message-ID: <kr0aofINNkq0@network.ucsd.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!mips!sdd.hp.com!network.ucsd.edu!lyapunov.ucsd.edu!mbk

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d441b227c44d1e53,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-02-29 16:58:08 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!mips!sdd.hp.com!network.ucsd.edu!lyapunov.ucsd.edu!mbk
From: mbk@lyapunov.ucsd.edu (Matt Kennel)
Newsgroups: gnu.gcc.help
Subject: Noalias??
Date: 1 Mar 1992 00:53:35 GMT
Organization: University of California, San Diego
Lines: 51
Message-ID: <kr0aofINNkq0@network.ucsd.edu>
NNTP-Posting-Host: lyapunov.ucsd.edu