4 ms·
The C code is a low level implementation of population count. AggressiveInstCombine.cpp first matches and raises the IR for this into llvm.ctpop.i64. https://g
by CalChris 2y ago
The C code is a low level implementation of population count. AggressiveInstCombine.cpp first matches and raises the IR for this into llvm.ctpop.i64.
https://godbolt.org/z/8ronKz3Eb https://godbolt.org/z/8ronKz3Eb
Later an x86 backend can re-lower this into a popcnt instruction or to CPOP on a RISC-V backend or to CNT on ARMv8 or ….
https://godbolt.org/z/4zvWs6rzr https://godbolt.org/z/4zvWs6rzr
It can also be re-lowered to roughly those instructions on machines lacking population count instructions.
https://godbolt.org/z/aYsc9dz7f https://godbolt.org/z/aYsc9dz7f