[dmd-internals] Shift support for vector types (or: is vector type a first class type?)

Kai Nacke kai at redstar.de
Sun Mar 31 18:56:38 PDT 2013


Hi!

I try to write a generic vectorized version of SHA1. During that I 
noticed that only some operations are allowed on vector types.

For the SHA1 algorithm I need to implement a 'rotate left'. I like to 
write something like this

     uint4 w = ...;
     uint4 v = (w << 1) | (w >> 31);

which is not allowed by DMD.

Is this by design or simply not implemented because the backend is not 
capable of generating code for it? The TDPL says nothing about vector 
types. My understanding of the language reference on the web 
(http://dlang.org/simd.html) is that the supported operators are CPU 
architecture dependent.

I really like to see more support for vector operations in the language, 
e.g. for shifting. What is the view of the language designers? Is the 
vector type a first class type or just an architecture (maybe vendor) 
dependent type with limited usability?

Because LLVM treats the vector type as a first class type supporting 
more operators is easy with LDC. See my pull request for shift operators 
here: https://github.com/ldc-developers/ldc/pull/321

Regards
Kai


More information about the dmd-internals mailing list