HACKER Q&A
📣 ncmncm

How to add POPCNT to the next RISC-V base or ā€œCā€ set?


RISC-V is an important development, but its academic roots show in its poor bit-manipulation capabilities. The Bitmanip extension, while an impressive effort, has languished, and in any case will not be implemented in most chips even if ever adopted, as it appears huge, and any particular application needs only a subset of it.

A huge part of the value of the Bitmanip extension would be provided by a single, minimal POPCNT instruction. How does one go about getting that into the next release of the base or "C" compressed instruction set? Is there any possibility of getting it into "C" compressed but not base set? Of Bitmanip claiming any part of the "C" code space?


  👤 childintime Accepted Answer ✓
Agreed on the sentiment.

There is zero chance of getting it into the base, C or even M sets, as they have existing implementations. But maybe a lone Z (without the usual lowercase letters) could mean just this instruction.

I found this to be a helpful discussion: https://www.embecosm.com/2019/10/22/gcc-risc-v-bit-manipulat...