[libcxx-commits] [libcxx] [libc++] Optimize `to_chars` for bases 2, 8 and 16 (PR #223222)

Jan Schultke via libcxx-commits libcxx-commits at lists.llvm.org
Sun Sep 13 04:51:45 PDT 2026


https://github.com/eisenwave commented:

Seems like a reasonable optimization, but
- As Zingam mentioned, some of those builtins might need feature-tests. `__builtin_bit_cast` is also more recent than `std::to_chars`.
- Any performance analysis should be cautious of the notoriously expensive early Zen BMI2 implementation, which is done in microcode. I imagine that attempting to use a `pdep` instruction on that architecture is strictly worse. https://godbolt.org/z/bvcjTo5sP https://godbolt.org/z/xE885Pzzc From what I can tell, we don't software-emulate `pdep` on Zen 2, so you're really getting that dramatic performance regression too. Anyway, that makes me think we want to keep the whole original implementation and only conditionally use the new one if it's not on Zen 2.

https://github.com/llvm/llvm-project/pull/223222


More information about the libcxx-commits mailing list