Paul Brook <[EMAIL PROTECTED]> writes: > > In general there is a conflict within gcc between treating vectors as > > unitary types and treating them as collections. In this case we are > > treating them as unary. However, I think that by analogy to the way > > we handle arithmetic, and given the existence of instructions like > > cvtdq2ps in real vector processors, I think it would be better to > > handle converstions on an element by element basis. > > > > That is, I think this is a bug. > > In that case I'd expect to be able to convert between eg. V2SF and V2DF.
I feel comfortable rejecting that (a cast between vector types of different sizes) as an error until and unless we implement [] for vector types. But I can see that it would sometimes be useful. > It also raises the question of what should be done in cases where there is no > obvious conversion. eg. V4SF to V2DF. Presumably this should be an error. I was just thinking about a slightly more interesting and reasonably common case, which is the cast between V4SI and V2DI. Real vector code on some processors does do that and requires it to be efficient. And for that we clearly want VIEW_CONVERT_EXPR. Which suggests: * same number of elements, elements have same size: convert element by element * same number of elements, elements have different size: either error or convert element by element * different number of elements, total size is the same, elements are all integral or all floating point: bitwise cast (VIEW_CONVERT_EXPR) * different number of elements, total size is the same, elements are not all integral or all floating point: error * different number of elements, total size is different: error But this is obviously potentially confusing. So I don't know if it is really a good idea. There is also the issue of which casts are done implicitly and which require an explicit cast. See vector_types_convertible_p. Currently you can assign between vector types of the same size without a cast, even if they have different number of elements. I think that is confusing and should probably be forbidden. It raises particular issues with C++ function overloading. Ian