[libre-riscv-dev] vector ops

Jacob Lifshay programmerjake at gmail.com
Mon Sep 16 09:44:34 BST 2019


CCing isa-dev at request of Luke.

In the page at
https://libre-riscv.org/simple_v_extension/vector_ops/

I definitely think SLERP shouldn't be a HW instruction, it is not used
often enough and has several trig function calls as well as having
dozens of flops worth of computation per subvector.

normalize is about my limit for internal complexity that I think might
be worth-while to implement as a HW instruction.

dot product definitely can be a HW instruction, and cross product might.

cross product should be able to be implemented with a four shuffles,
one element-wise multiply, and one element-wise mulsub:

vec3 a, b; // elements in order a.x, a.y, a.z
// compute a cross b:
vec3 t1 = a.yzx; // produce vector [a.y, a.z, a.x]
vec3 t2 = b.zxy;
vec3 t3 = a.zxy;
vec3 t4 = b.yzx;
vec3 p = t3 * t4;
vec3 cross = t1 * t2 - p;

Jacob



More information about the libre-riscv-dev mailing list