On Thu, 13 Sep 2012, Jason Merrill wrote:
Furthermore, this builtin support would be useful for implementing
a C++ class for vector arithmetic, just as it is with std::complex. I'm not
aware of any other portable way to implement such a class.
I forgot to say: it is always possible to do the operations elementwise:
__m128d x,y;
__m128i cmp={(x[0]<y[0])?-1:0,(x[1]<y[1])?-1:0};
(__m128d is a pair of double, __m128i a pair of long long)
This counts on the middle-end to recognize the patterns. But that will
have to be implemented anyway, possibly for sqrt, and certainly for type
conversions:
__m128i i;
__m128d x={i[0],i[1]};
because the sensible syntax (__m128d)i has been taken to mean
*(__m128d*)&i :-(
(it is also possible to add __builtin_convert, __builtin_math_sqrt, etc)
--
Marc Glisse