Noalias trivia question

Doug Gwyn gwyn at brl-smoke.ARPA
Thu May 5 04:29:29 AEST 1988


In article <871 at sun.mcs.clarkson.edu> mrd at sun.mcs.clarkson.edu (Michael R. DeCorte) writes:
>I NEED something that will allow me to write a C
>compiler that can vectorize and concurentize code.  What should I do?

The first thing you need to realize is that C has always been capable of
aliasing objects via pointers, and it has been (tacitly) assumed that all
references to aliased objects will access the same thing, not distinct
cached copies of the object.  Thus, C has never permitted optimization
along the lines that people expect for Fortran.  To obtain such optimization
it is incumbent on the programmer to take some special steps to flag those
cases that can be optimized, unless his system provides really good global
flow analysis across multiple translation units (source files).  "noalias"
is not the only possible mechanism for this; a less ambitious one would
be a vendor-specific hook such as a compiler option, a magic /*comment*/,
or even a __keyword that flags places where aliasing can safely be ignored.
The obvious such place is at function interfaces, since it is extremely
poor style for a function to be required to access the same object both
directly as an extern and indirectly via a pointer parameter.  It has been
suggested that [] formal parameters have this special meaning, although
they can't by default in a Standard-conforming implementation (you would
have to enable the special treatment by a compiler option).  There is some
disagreement whether #pragma can be used to change such semantics.  Both
the Redactor (draft Standard editor) and I think not, but I've heard other
X3J11 members voice contrary opinions.

You should discuss this with your compiler vendor.  First ask for good
global data access analysis (although it's unlikely that you'll get it),
then ask for a compiler flag for special treatment of [] parameters, then
ask for a __keyword.



More information about the Comp.lang.c mailing list