Vector operations
Created by: wks
Some modern processors provide SIMD instructions. Using them properly can greatly increase the performance of some computations. The µVM should expose them to the user.
LLVM's approach:
- Vector types are first-class types. Most instructions which accept scalar values also accept vector values.
- Binary operations are done element-wise.
- Comparison operations are done element-wise, resulting in a vector of one-bit integers.
- Conversions can be done between integer vectors, integer vector to FP vector, but not between different FP types (no fptrunc and fpext for vectors)
- The select instruction works with vector condition with vector values, and also scalar condition with vector values.
- extractelement and insertelement to build and extract element from vectors
- shufflevector: repermutate elements of two vectors
- All other instructions that work with first-class types, including phi, ret, function calls, the contents to load/store.
- LLVM does not address scatter/gather.
Things to be done in the µVM
- Alignment requirements.
- Provide extra intrinsic functions to support machine-provided operations not covered by the
BinOp
µVM instruction. Example: reciprocal, exp, log, abs, ...