4 ms·
Assuming that vector instructions are available, shouldn't it be much faster to actually compare the buffer contents against a vector register initialized to al
by TonyTrapp 5y ago
Assuming that vector instructions are available, shouldn't it be much faster to actually compare the buffer contents against a vector register initialized to all-zeros rather than comparing against some other memory? Or would memcmp automatically optimize that away because of the precondition that the first 16 bytes are already known to be 0?
- BeeOnRope 5y agoIt is probably faster, yes (half the number of reads) – but the point of this truck is that you can re-use the (hopefully) vectorized memcmp on every platform with portable code rather than getting on the SIMD ISA treadmill yourself.
- rwmj 5y agoThe qemu implementation does indeed do it the hard way. It's a lot of code: https://gitlab.com/qemu-project/qemu/-/blob/master/util/bufferiszero.c https://gitlab.com/qemu-project/qemu/-/blob/master/util/buff...
- pm215 5y agoInterestingly, we used to have a special-case aarch64 version, but we dropped it because the C version was faster: https://gitlab.com/qemu-project/qemu/-/commit/2250d3a293d36ed9d8143d4c3d3e94086c429af4 https://gitlab.com/qemu-project/qemu/-/commit/2250d3a293d36e... (Might or might not still be true on more modern aarch64 hardware...)
- pm215 5y agoDoes your memset version beat QEMU's plain-old-C fallback version ?