llvm-project
274a4c0c - [libc++] Optimize std::has_single_bit (#133063)

Commit
45 days ago
[libc++] Optimize std::has_single_bit (#133063) Clang translates most implementations of has_single_bit to `(v ^ (v-1)) > v-1` - except the one definition libc++ actually uses. Proof of correctness: https://godbolt.org/z/d61bxW4r1 (Could also be fixed by teaching Clang to optimize better, but making source match output feels clearer to me. And it improves unoptimized performance.)
Author
Parents
Loading