[PATCH] D52697: Bug 39129: Speeding up partition_point/lower_bound/upper_bound/ by using unsigned division by 2 when possible.

Marshall Clow via Phabricator reviews at reviews.llvm.org
Sun Sep 30 15:14:19 PDT 2018


mclow.lists added a comment.

In https://reviews.llvm.org/D52697#1250269, @dyaroshev wrote:

> - In general, this is the kind of optimization that I would rather see the compiler do (everywhere, automatically) than libc++ (here and there, manually).
>
>   I don't think it can, can it? The optimization comes from knowing the last - first will never be < 0. How would the compiler know that?


We can tell the compiler that `std::distance` always returns >= 0.
The optimizer already knows a lot about various standard library calls.


https://reviews.llvm.org/D52697





More information about the libcxx-commits mailing list