Daniel Keep wrote:

bearophile wrote:
Michel Fortin:
Instead of introducing new a new type, couldn't float[4] be the one mapped to a vector type? Why do we need a new type?
Alignment requirements, shuffling operations, scalar operations on just the 
first item of the vector, ecc. It may be doable, and it may be even a nice 
idea, but probably it requires lot of care.

Bye,
bearophile

Another advantage would be that you could specify in the ABI that this
vector type should be passed to and returned from functions via the XMM
registers.  You could make a specific exception for float[4], but that
just seems messy.

  -- Daniel

I don't think that's messy at all. I can't see much difference between special support for float[4] versus float4. It's better if the code can take advantage of hardware without specific support. Bear in mind that SSE/SSE2 is a temporary situation. AVX provides for much longer arrays of vectors; and it's extensible. You'd end up needing to keep adding on special types whenever a new CPU comes out.

Note that the fundamental concept which is missing from the C virtual machine is that all modern machines can efficiently perform operations on arrays of built-in types of length 2^n, for some small value of n. We need to get this into the language abstraction. Not follow C++ in hacking a few extra special types onto the old, deficient C model. And I think D is actually in a position to do this.

float[4] would be a greatly superior option if it could be done.
The key requirements are:
(1) need to specify that static arrays are passed by value.
(2) need to keep stack aligned to 16.
The good news is that both of these appear to be done on DMD2-Mac!

Reply via email to