On Apr 19, 2006, at 1:56 PM, Mark Mitchell wrote:
Let's accept that both the bit-preserving and value-preserving
conversions would be useful. How do we differentiate the two?
For vectors, these operators would apply to each element, and then
return a vector with the same number of elements as the input vector.
I suppose that we could introduce these operators into C as well,
although the pseudo-template syntax might not be as natural for C
users.
If you're interested in adding value for generic vectors, it may be
interesting to consider element access operations. Being able to
write things like:
float X = V[1];
or
V[2] = X;
... would be incredibly useful for people trying to use generic
vectors when they can. In particular, it makes it possible to
generate good code for common operations like splat/broadcast
operations, where without element access you have to go through
memory. An example would look like this:
vector v1, v2 = ...
v1 = (vector){v2[0], v2[0], v2[0], v2[0]};
Currently the only way to get or set elements of a vector is with non-
TBAA safe pointer arithmetic and vector/array unions.
I've recently been working with people trying to use generic vectors,
and I feel that insertion/extraction is more important than type
conversion operations. This is because they generally map better to
hardware and provide a way to access various shuffle operations. As
it has been noted, various vector ISA's are quite non-orthogonal when
it comes to type conversion operations, but they do generally have
efficient ways to do common permute operations (e.g. splat).
Further, the syntax is trivial and common between C/C++. That said,
any forward progress on generic vector support is great! :)
-Chris