[libcxx-commits] [libcxx] [libc++] Vectorize std::adjacent_find (PR #89757)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Oct 18 08:42:07 PDT 2024
================
@@ -39,10 +44,84 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
return __i;
}
+template <class _Iter, class _Sent, class _BinaryPredicate>
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
+__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
+ return std::__adjacent_find_loop(__first, __last, __pred);
+}
+
+#if _LIBCPP_VECTORIZE_ALGORITHMS
+
+template <class _Tp, class _Pred>
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp*
+__adjacent_find_vectorized(_Tp* __first, _Tp* __last, _Pred& __pred) {
----------------
ldionne wrote:
Just recording our discussion: If we instead processed the head of the sequence in a loop, we could potentially set things up to ensure that the vectorized part of the algorithm only has to work with properly aligned memory, which could be faster. That would need benchmarking.
https://github.com/llvm/llvm-project/pull/89757
More information about the libcxx-commits
mailing list