Daniel Keep wrote: > Andrei Alexandrescu wrote: >> Denis Koroskin wrote: >>> On Thu, 19 Feb 2009 22:25:04 +0300, Mattias Holm >>> <hannibal.h...@gmail.com> wrote: >>> >>>> Since (SIMD) vectors are so common and every reasonabe system support >>>> them in one way or the other (and scalar emulation of this is rather >>>> simple), why not have support for this in D directly? >>>> >>>> [snip] >>> I don't see any reason why float4 can't be made a library type. >> Yah, I was thinking the same: >> >> struct float4 >> { >> __align(16) float[4] data; // right syntax and value? >> alias data this; >> } >> >> This looks like something that should go into std.matrix pronto. It even >> has value semantics even though fixed arrays don't :o/. >> >> >> Andrei > > I remember implementing a vector struct [1] quite some time ago that had > an SSE-accelerated path.
We have that in dglut too :) It's optimized for the float[3]/float[4] case - all float[3]s add a hidden bogus member, then the arithmetic operations generate for loops which are very easy for a properly patched gdc to autovectorize :) No loss of inlining, which means no ref VS. val issues. Alignment is still a problem, but movups in the aligned case is just as fast as movaps, so I figure it doesn't matter that much. Autovec is sweet.