3 ms·
sorry i am out of loop here. what specifically is the problem with POPCNT on AMD64?
by hawk_ 5y ago
sorry i am out of loop here. what specifically is the problem with POPCNT on AMD64?
- ncmncm 5y agoPOPCNT was added to amd64 in 2003. Because there are still amd64 machines from before then, compilers don't produce POPCNT instructions unless directed to target a later chip. MSVC emits them to implement extension _popcount, but does not use that in its stdlib. Gcc, without a directive, expands __builtin_popcount to much slower code. You can check for a "capability", but testing and branching before a POPCNT instruction adds latency and burns a precious branch prediction slot. Most of the useful instructions on RISC-V are in optional extensions. Sometimes this is OK because you can put a whole loop behind a feature test. But some of these instructions would tend to be isolated and appear all over. That is the case for memcpy and memset, too, which often operate over very small blocks.
- deleted 5y ago[deleted]