[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
Mon Oct 1 11:07:50 PDT 2018
mclow.lists added inline comments.
================
Comment at: include/algorithm:3213
+ _Integral
+ >::type __size_t_if_safe;
+
----------------
mclow.lists wrote:
> dyaroshev wrote:
> > mclow.lists wrote:
> > > Does `make_unsigned` do what you want here?
> > I don't think so. Seems like size_t if faster than unsigned: http://quick-bench.com/hATsToKHx8UP3legquGgvT-4qpU
> > (this is not only this benchmark, I've seen other cases when it happens.
> I think we may be talking about different things.
>
> I was talking about the template metafunction `std::make_unsigned`, which gives you an unsigned type with the same size as the parameter.
>
> From your comment, I get the feeling you are talking about the literal type `unsigned`.
>
If I change line 9 in your quickbench example to:
using len_type = std::make_unsigned_t<typename std::iterator_traits<I>::difference_type>;
then the two chunks of code run at the same speed.
https://reviews.llvm.org/D52697
More information about the libcxx-commits
mailing list