[libcxx-commits] [libcxx] [libc++] Optimize bitset::to_string (PR #128832)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 26 10:15:17 PST 2025
philnik777 wrote:
```c++
template <class T>
using vec __attribute__((ext_vector_type(8))) = T;
void to_string(char* buf, unsigned char bools, char a, char b) {
*(vec<char>*)buf = __builtin_bit_cast(vec<bool>, bools) ? a : b;
}
```
this works on eight bits at a time. We probably want to try and write it in a way that generates code based on the `bitset` size. With AVX512 we should get some incredibly efficient code here.
https://github.com/llvm/llvm-project/pull/128832
More information about the libcxx-commits
mailing list