[libre-riscv-dev] Some general instruction ideas

Lauri Kasanen cand at gmx.com
Fri Jan 24 13:44:57 GMT 2020


I wanted to float some general instruction ideas, now that things seem
to be picking up. I've mentioned some to Luke previously. These have
use in video, but also in general.

- altivec's vec_perm. It's a byte shuffle with three input regs and one
output. It's exceedingly useful, more powerful than any of x86's
shuffles, and I believe it should be copied as-is.

- saturated versions of add/sub/mul/narrow/etc. Saves those manual
checks. Beyond video, often used in image processing.

- memcpy. I remember a Linus quote on what instructions he'd like to
see, and he said memcpy and memset. I know it's not very RISC, but it's
highly useful, and a hardware loop is always faster than sw.

One cpu I'm familiar with, 65816, has two such memcpy instructions
(forward and backward, byte units). They have no hidden state, and are
interruptable between every byte. By giving them overlapping areas,
they work as memset, with an arbitrary-sized source pattern, not just
limited to a byte or int.

Such would have immediate use in decompression, and widely in general.
It would also give a clear answer for "what is the fastest memcpy", heh.

- Lauri

More information about the libre-riscv-dev mailing list