[libcxx-commits] [libcxx] [libc++] Optimize string operator[] for known large inputs (PR #69500)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 25 09:25:48 PDT 2023


ldionne wrote:

> And what about for non-constant string indexes?

Right, in this case `__builtin_constant_p` will evaluate to `false`, so it is extremely unlikely that the compiler will generate any code for the `if` branch. Basically this seems to be a free optimization.

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


More information about the libcxx-commits mailing list