casting "extended vectors"

Marc Glisse marc.glisse@inria.fr
Sun Jul 6 14:57:00 GMT 2014


On Sun, 6 Jul 2014, Vincenzo Innocente wrote:

>>> Is it possible to cast “vectors”  as in C one casts intrinsic types?
>>
>> Not directly, no. You can cast element by element and hope gcc will vectorize it, but I don't even think that is likely.
>     VF convert(itype i) { VF f; for (int j=0;j<N;++j) f[j]=i[j]; return f;}
>    itype convert(VF f) { itype i; for (int j=0;j<N;++j) i[j]=f[j]; return i;}
> vectorize for N=8  and N=16, does not vectorize for N=4 (independently of the target architecture)

Even for N=8 or 16, if you inline convert, it won't vectorize anymore. The 
vectorizer needs to see a non-local object to start working.

> strange syntax indeed. of course in c++ would be trivialÂ… 
> "__builtin_convertvector<T>”
> It that would be a very welcome addition whatever syntax you 
> choose/manage-to-implement
>
> If you can also try to add something for “movemask” would be also great!

Please file enhancement PRs (after making sure they don't already exist) 
with as much information as you can. I am unlikely to implement that any 
time soon, maybe somebody else will be...

For the vector extension, we don't want things that are too specific to a 
processor. Maybe an operation that takes an integer vector guaranteed to 
have only 0 and -1 as elements and compacting it to a bitfield would make 
sense (and the reverse operation), this would be relevant for sparc-vis 
and for avx512. Movemask seems a bit too weird for direct support.

-- 
Marc Glisse



More information about the Gcc-help mailing list