[PATCH] D52697: Bug 39129: Speeding up partition_point/lower_bound/upper_bound/ by using unsigned division by 2 when possible.
Eric Fiselier via Phabricator
reviews at reviews.llvm.org
Thu Oct 25 11:10:36 PDT 2018
EricWF requested changes to this revision.
EricWF added inline comments.
This revision now requires changes to proceed.
================
Comment at: include/algorithm:754
+// Perform division by two quickly for positive integers (llvm.org/PR39129)
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 ptrdiff_t
+__half_positive(ptrdiff_t __value)
----------------
dyaroshev wrote:
> EricWF wrote:
> > I think we can use `_LIBCPP_CONSTEXPR` here and get better behavior in C++03.
> Sure, will do.
>
> Why _LIBCPP_CONSTEXPR helps in C++03?
Woops. I meant to write "C++11".
My mistake.
================
Comment at: test/libcxx/algorithms/half_positive.pass.cpp:31
+
+ _LIBCPP_CONSTEXPR type max_v = std::numeric_limits<type>::max();
+ _LIBCPP_CONSTEXPR type r = std::__half_positive(max_v);
----------------
Other libraries run our test suite, so we can't use internal macros.
Could you please write one set of tests that run at runtime, and another set that uses constexpr and static assert.
And then guard the constexpr tests under `#if TEST_STD_VER >= 11`.
https://reviews.llvm.org/D52697
More information about the libcxx-commits
mailing list