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

Denis Yaroshevskiy via Phabricator reviews at reviews.llvm.org
Mon Oct 1 10:07:33 PDT 2018


dyaroshev added a comment.

In https://reviews.llvm.org/D52697#1251168, @lebedev.ri wrote:

> FWTW just adding an assume is *NOT* enough, sadly.
>  https://godbolt.org/z/v8fjnG


Good thinking though. I checked in libstdc++ (they don't have this performance issue).
They just do right shift instead of casting to unsigned: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_algobase.h#L972
I'm not too sure how >> works, but if their way works for you, it looks simpler. (I don't know the concept requirements for difference type, but libstdc++ guys seem to require >> operation - which probably means it's OK).
http://quick-bench.com/9tsZ0ZTUn0bUTy1gPBvFnpYD4oA


https://reviews.llvm.org/D52697





More information about the libcxx-commits mailing list