On 22/09/11 1:38 AM, Walter Bright wrote:
D doesn't have __restrict. I'm going to argue that it is unnecessary.
AFAIK, __restrict is most used in writing vector operations. D, on the
other hand, has a dedicated vector operation syntax:
a[] += b[] * c;
where a[] and b[] are required to not be overlapping, hence enabling
parallelization of the operation.
It's used for vector stuff, but I wouldn't say mostly. Just about any
performance intensive piece of code involving pointers can benefit from
__restrict. I use it in a VM for example.
As an extension from that, why is there no hardware vector support
in the language? Surely a primitive vector4 type would be a sensible
thing to have?
The language supports it now (see the aforementioned vector syntax),
it's just that the vector code gen isn't done (currently it is just
implemented using loops).
I don't see how this would be possible without intrinsics, or at least
some form of language extension.
Would DMD just *always* put float[4] in XMM registers (assuming they are
available)?
That doesn't seem like a good idea if you don't want to use it as a vector.
BTW, if you want to get a good idea of how game programmers use vector
intrinsics on current hardware, there is a good blog post about it here:
http://altdevblogaday.com/2011/01/31/vectiquette/