Pointer aliasing in D (Was: Programming language benchmarks)

Jens Mueller jens.k.mueller at gmx.de
Thu Apr 28 11:44:50 PDT 2011


Andrei Alexandrescu wrote:
> On 4/28/11 12:57 PM, Jens Mueller wrote:
> >Walter Bright wrote:
> >>On 4/28/2011 9:19 AM, Daniel Gibson wrote:
> >>>But there's no need for a D compiler to optimize loops that just copy
> >>>parts of an array into another array (and similar stuff), because in D
> >>>you use slices for that - they're (probably) faster and easier to use.
> >>>So IMHO it's fair to use slices where possible.
> >>>(And they're a language feature and not just part of the library)
> >>>Furthermore this particular benchmark is a "programming language
> >>>benchmark" and not a compiler benchmark, so it's fair to use every
> >>>feature of the language.
> >>
> >>
> >>For example, a lot of effort is expended in C and Fortran compilers
> >>"reverse engineering" loops so they can be recompiled and optimized
> >>as vector operations. I don't see ever bothering with this in D
> >>compilers, as D offers a vector notation.
> >
> >If somebody wants to read the elaborate version of the above:
> >http://drdobbs.com/blogs/229300270
> >Walter's Dr. Dobb's articles are very good. I only read the new ones
> >posted. But I have to read the older ones if I find some time.
> >BTW
> >In the book "Coder at Work" Fran Allen takes a quite strong position
> >against C. She was deeply into Fortran compilers. She says: "We have
> >seriously regressed, since C developed. C has destroyed our ability to
> >advance the state of the art in automatic optimization, automatic
> >parallelization, automatic mapping of a high-level language to the
> >machine."
> >When I read this some time ago I found that position quite interesting.
> >But unfortunately I cannot tell how valid it is. Walter with all of his
> >experience in developing compilers may give a well informed evaluation
> >on Allen's statement. I'm just curious.
> >
> >Jens
> 
> It's simple - Fortran can assume that all data is unaliased
> (although aliasing is still technically possible). C, with its
> intensive pointer-based ethos that makes many aliasing-related
> optimizations difficult, has annoyed many a Fortran aficionados.

Thanks. So if a compiler can assume that pointers do not alias it can
generate much better code. What's D's standpoint on that matter then?
C99 has restrict. I never came across something similar in D.

Jens


More information about the Digitalmars-d mailing list