diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:25:56 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-10 19:25:56 +0900 |
commit | 63f5dc16d6bfca0512fb034052b41d13c3751e20 (patch) | |
tree | e70266be1fda941e0974e71e3d2c1cf080081311 /libcxx/include/__algorithm | |
parent | 9e5734688ed3d5f6b3fb76a26b3d90a736d60781 (diff) | |
parent | 397ac44f623f891d8f05d6673a95984ac0a26671 (diff) | |
download | llvm-users/chapuni/cov/single/unify.zip llvm-users/chapuni/cov/single/unify.tar.gz llvm-users/chapuni/cov/single/unify.tar.bz2 |
Merge branch 'main' into users/chapuni/cov/single/unifyusers/chapuni/cov/single/unify
Diffstat (limited to 'libcxx/include/__algorithm')
-rw-r--r-- | libcxx/include/__algorithm/comp_ref_type.h | 4 | ||||
-rw-r--r-- | libcxx/include/__algorithm/copy.h | 2 | ||||
-rw-r--r-- | libcxx/include/__algorithm/iterator_operations.h | 18 | ||||
-rw-r--r-- | libcxx/include/__algorithm/mismatch.h | 8 | ||||
-rw-r--r-- | libcxx/include/__algorithm/move.h | 2 | ||||
-rw-r--r-- | libcxx/include/__algorithm/ranges_iterator_concept.h | 2 | ||||
-rw-r--r-- | libcxx/include/__algorithm/ranges_unique_copy.h | 2 | ||||
-rw-r--r-- | libcxx/include/__algorithm/simd_utils.h | 83 | ||||
-rw-r--r-- | libcxx/include/__algorithm/sort.h | 4 | ||||
-rw-r--r-- | libcxx/include/__algorithm/three_way_comp_ref_type.h | 4 | ||||
-rw-r--r-- | libcxx/include/__algorithm/unwrap_iter.h | 2 |
11 files changed, 54 insertions, 77 deletions
diff --git a/libcxx/include/__algorithm/comp_ref_type.h b/libcxx/include/__algorithm/comp_ref_type.h index c367fbb..6a9d5ce 100644 --- a/libcxx/include/__algorithm/comp_ref_type.h +++ b/libcxx/include/__algorithm/comp_ref_type.h @@ -56,10 +56,10 @@ struct __debug_less { // Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference. #if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG template <class _Comp> -using __comp_ref_type = __debug_less<_Comp>; +using __comp_ref_type _LIBCPP_NODEBUG = __debug_less<_Comp>; #else template <class _Comp> -using __comp_ref_type = _Comp&; +using __comp_ref_type _LIBCPP_NODEBUG = _Comp&; #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h index 4f30b20..962aa90 100644 --- a/libcxx/include/__algorithm/copy.h +++ b/libcxx/include/__algorithm/copy.h @@ -47,7 +47,7 @@ struct __copy_impl { template <class _InIter, class _OutIter> struct _CopySegment { - using _Traits = __segmented_iterator_traits<_InIter>; + using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>; _OutIter& __result_; diff --git a/libcxx/include/__algorithm/iterator_operations.h b/libcxx/include/__algorithm/iterator_operations.h index 6cdb0ae..e5c89c1 100644 --- a/libcxx/include/__algorithm/iterator_operations.h +++ b/libcxx/include/__algorithm/iterator_operations.h @@ -48,13 +48,13 @@ struct _RangeAlgPolicy {}; template <> struct _IterOps<_RangeAlgPolicy> { template <class _Iter> - using __value_type = iter_value_t<_Iter>; + using __value_type _LIBCPP_NODEBUG = iter_value_t<_Iter>; template <class _Iter> - using __iterator_category = ranges::__iterator_concept<_Iter>; + using __iterator_category _LIBCPP_NODEBUG = ranges::__iterator_concept<_Iter>; template <class _Iter> - using __difference_type = iter_difference_t<_Iter>; + using __difference_type _LIBCPP_NODEBUG = iter_difference_t<_Iter>; static constexpr auto advance = ranges::advance; static constexpr auto distance = ranges::distance; @@ -72,13 +72,13 @@ struct _ClassicAlgPolicy {}; template <> struct _IterOps<_ClassicAlgPolicy> { template <class _Iter> - using __value_type = typename iterator_traits<_Iter>::value_type; + using __value_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type; template <class _Iter> - using __iterator_category = typename iterator_traits<_Iter>::iterator_category; + using __iterator_category _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; template <class _Iter> - using __difference_type = typename iterator_traits<_Iter>::difference_type; + using __difference_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; // advance template <class _Iter, class _Distance> @@ -94,10 +94,10 @@ struct _IterOps<_ClassicAlgPolicy> { } template <class _Iter> - using __deref_t = decltype(*std::declval<_Iter&>()); + using __deref_t _LIBCPP_NODEBUG = decltype(*std::declval<_Iter&>()); template <class _Iter> - using __move_t = decltype(std::move(*std::declval<_Iter&>())); + using __move_t _LIBCPP_NODEBUG = decltype(std::move(*std::declval<_Iter&>())); template <class _Iter> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static void __validate_iter_reference() { @@ -217,7 +217,7 @@ private: }; template <class _AlgPolicy, class _Iter> -using __policy_iter_diff_t = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>; +using __policy_iter_diff_t _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__algorithm/mismatch.h b/libcxx/include/__algorithm/mismatch.h index f585537..a683679 100644 --- a/libcxx/include/__algorithm/mismatch.h +++ b/libcxx/include/__algorithm/mismatch.h @@ -78,7 +78,7 @@ __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { } for (size_t __i = 0; __i != __unroll_count; ++__i) { - if (auto __cmp_res = std::__as_mask(__lhs[__i] == __rhs[__i]); !std::__all_of(__cmp_res)) { + if (auto __cmp_res = __lhs[__i] == __rhs[__i]; !std::__all_of(__cmp_res)) { auto __offset = __i * __vec_size + std::__find_first_not_set(__cmp_res); return {__first1 + __offset, __first2 + __offset}; } @@ -90,7 +90,7 @@ __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { // check the remaining 0-3 vectors while (static_cast<size_t>(__last1 - __first1) >= __vec_size) { - if (auto __cmp_res = std::__as_mask(std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2)); + if (auto __cmp_res = std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2); !std::__all_of(__cmp_res)) { auto __offset = std::__find_first_not_set(__cmp_res); return {__first1 + __offset, __first2 + __offset}; @@ -107,8 +107,8 @@ __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { if (static_cast<size_t>(__first1 - __orig_first1) >= __vec_size) { __first1 = __last1 - __vec_size; __first2 = __last2 - __vec_size; - auto __offset = std::__find_first_not_set( - std::__as_mask(std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2))); + auto __offset = + std::__find_first_not_set(std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2)); return {__first1 + __offset, __first2 + __offset}; } // else loop over the elements individually } diff --git a/libcxx/include/__algorithm/move.h b/libcxx/include/__algorithm/move.h index 005099d..6f3b0eb 100644 --- a/libcxx/include/__algorithm/move.h +++ b/libcxx/include/__algorithm/move.h @@ -50,7 +50,7 @@ struct __move_impl { template <class _InIter, class _OutIter> struct _MoveSegment { - using _Traits = __segmented_iterator_traits<_InIter>; + using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>; _OutIter& __result_; diff --git a/libcxx/include/__algorithm/ranges_iterator_concept.h b/libcxx/include/__algorithm/ranges_iterator_concept.h index 2af891d..58790e9 100644 --- a/libcxx/include/__algorithm/ranges_iterator_concept.h +++ b/libcxx/include/__algorithm/ranges_iterator_concept.h @@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() { } template <class _Iter> -using __iterator_concept = decltype(__get_iterator_concept<_Iter>()); +using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>()); } // namespace ranges _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__algorithm/ranges_unique_copy.h b/libcxx/include/__algorithm/ranges_unique_copy.h index 3b4a64e..ee7f0a0 100644 --- a/libcxx/include/__algorithm/ranges_unique_copy.h +++ b/libcxx/include/__algorithm/ranges_unique_copy.h @@ -60,7 +60,7 @@ struct __unique_copy { } template <class _InIter, class _OutIter> - using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>()); + using __algo_tag_t _LIBCPP_NODEBUG = decltype(__get_algo_tag<_InIter, _OutIter>()); template <input_iterator _InIter, sentinel_for<_InIter> _Sent, diff --git a/libcxx/include/__algorithm/simd_utils.h b/libcxx/include/__algorithm/simd_utils.h index 3ca7924..4e03723 100644 --- a/libcxx/include/__algorithm/simd_utils.h +++ b/libcxx/include/__algorithm/simd_utils.h @@ -70,7 +70,7 @@ struct __get_as_integer_type_impl<8> { }; template <class _Tp> -using __get_as_integer_type_t = typename __get_as_integer_type_impl<sizeof(_Tp)>::type; +using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_impl<sizeof(_Tp)>::type; // This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance // in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms @@ -90,7 +90,7 @@ inline constexpr size_t __native_vector_size = 1; # endif template <class _ArithmeticT, size_t _Np> -using __simd_vector __attribute__((__ext_vector_type__(_Np))) = _ArithmeticT; +using __simd_vector __attribute__((__ext_vector_type__(_Np))) _LIBCPP_NODEBUG = _ArithmeticT; template <class _VecT> inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t { @@ -106,7 +106,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp, } template <class _VecT> -using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_type_impl(_VecT{})); +using __simd_vector_underlying_type_t _LIBCPP_NODEBUG = decltype(std::__simd_vector_underlying_type_impl(_VecT{})); // This isn't inlined without always_inline when loading chars. template <class _VecT, class _Iter> @@ -116,65 +116,42 @@ template <class _VecT, class _Iter> }(make_index_sequence<__simd_vector_size_v<_VecT>>{}); } -template <size_t _Np> -[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<bool, _Np> __vec) noexcept { - return __builtin_reduce_and(__vec); -} - template <class _Tp, size_t _Np> -[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI auto __as_mask(__simd_vector<_Tp, _Np> __vec) noexcept { - static_assert(!is_same<_Tp, bool>::value, "vector type should not be a bool!"); - return __builtin_convertvector(__vec, __simd_vector<bool, _Np>); -} - -// This uses __builtin_convertvector around the __builtin_shufflevector to work around #107981. -template <size_t _Np> -[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI __simd_vector<bool, 8> -__extend_vector(__simd_vector<bool, _Np> __vec) noexcept { - using _VecT = __simd_vector<bool, _Np>; - if constexpr (_Np == 4) { - return __builtin_convertvector( - __builtin_shufflevector(__vec, _VecT{}, 0, 1, 2, 3, 4, 5, 6, 7), __simd_vector<bool, 8>); - } else if constexpr (_Np == 2) { - return std::__extend_vector( - __builtin_convertvector(__builtin_shufflevector(__vec, _VecT{}, 0, 1, 2, 3), __simd_vector<bool, 4>)); - } else if constexpr (_Np == 1) { - return std::__extend_vector( - __builtin_convertvector(__builtin_shufflevector(__vec, _VecT{}, 0, 1), __simd_vector<bool, 2>)); - } else { - static_assert(sizeof(_VecT) == 0, "Unexpected vector size"); - } +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { + return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); } -template <size_t _Np> -[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI auto __to_int_mask(__simd_vector<bool, _Np> __vec) { - if constexpr (_Np < 8) { - return std::__bit_cast<uint8_t>(std::__extend_vector(__vec)); - } else if constexpr (_Np == 8) { - return std::__bit_cast<uint8_t>(__vec); - } else if constexpr (_Np == 16) { - return std::__bit_cast<uint16_t>(__vec); - } else if constexpr (_Np == 32) { - return std::__bit_cast<uint32_t>(__vec); - } else if constexpr (_Np == 64) { - return std::__bit_cast<uint64_t>(__vec); - } else { - static_assert(sizeof(__simd_vector<bool, _Np>) == 0, "Unexpected vector size"); - return 0; - } -} +template <class _Tp, size_t _Np> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { + using __mask_vec = __simd_vector<bool, _Np>; -template <size_t _Np> -[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<bool, _Np> __vec) noexcept { + // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876 + auto __impl = [&]<class _MaskT>(_MaskT) _LIBCPP_NO_SANITIZE("memory") noexcept { # if defined(_LIBCPP_BIG_ENDIAN) - return std::min<size_t>(_Np, std::__countl_zero(std::__to_int_mask(__vec))); + return std::min<size_t>( + _Np, std::__countl_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec)))); # else - return std::min<size_t>(_Np, std::__countr_zero(std::__to_int_mask(__vec))); + return std::min<size_t>( + _Np, std::__countr_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec)))); # endif + }; + + if constexpr (sizeof(__mask_vec) == sizeof(uint8_t)) { + return __impl(uint8_t{}); + } else if constexpr (sizeof(__mask_vec) == sizeof(uint16_t)) { + return __impl(uint16_t{}); + } else if constexpr (sizeof(__mask_vec) == sizeof(uint32_t)) { + return __impl(uint32_t{}); + } else if constexpr (sizeof(__mask_vec) == sizeof(uint64_t)) { + return __impl(uint64_t{}); + } else { + static_assert(sizeof(__mask_vec) == 0, "unexpected required size for mask integer type"); + return 0; + } } -template <size_t _Np> -[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<bool, _Np> __vec) noexcept { +template <class _Tp, size_t _Np> +[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept { return std::__find_first_set(~__vec); } diff --git a/libcxx/include/__algorithm/sort.h b/libcxx/include/__algorithm/sort.h index ed828b6..5c60b23 100644 --- a/libcxx/include/__algorithm/sort.h +++ b/libcxx/include/__algorithm/sort.h @@ -890,10 +890,10 @@ __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co } template <class _Type, class... _Options> -using __is_any_of = _Or<is_same<_Type, _Options>...>; +using __is_any_of _LIBCPP_NODEBUG = _Or<is_same<_Type, _Options>...>; template <class _Type> -using __sort_is_specialized_in_library = __is_any_of< +using __sort_is_specialized_in_library _LIBCPP_NODEBUG = __is_any_of< _Type, char, #if _LIBCPP_HAS_WIDE_CHARACTERS diff --git a/libcxx/include/__algorithm/three_way_comp_ref_type.h b/libcxx/include/__algorithm/three_way_comp_ref_type.h index 5702a1f..f6f7645 100644 --- a/libcxx/include/__algorithm/three_way_comp_ref_type.h +++ b/libcxx/include/__algorithm/three_way_comp_ref_type.h @@ -61,10 +61,10 @@ struct __debug_three_way_comp { // Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference. # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG template <class _Comp> -using __three_way_comp_ref_type = __debug_three_way_comp<_Comp>; +using __three_way_comp_ref_type _LIBCPP_NODEBUG = __debug_three_way_comp<_Comp>; # else template <class _Comp> -using __three_way_comp_ref_type = _Comp&; +using __three_way_comp_ref_type _LIBCPP_NODEBUG = _Comp&; # endif #endif // _LIBCPP_STD_VER >= 20 diff --git a/libcxx/include/__algorithm/unwrap_iter.h b/libcxx/include/__algorithm/unwrap_iter.h index 8cc0d22..b66a682 100644 --- a/libcxx/include/__algorithm/unwrap_iter.h +++ b/libcxx/include/__algorithm/unwrap_iter.h @@ -46,7 +46,7 @@ struct __unwrap_iter_impl { // It's a contiguous iterator, so we can use a raw pointer instead template <class _Iter> struct __unwrap_iter_impl<_Iter, true> { - using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>())); + using _ToAddressT _LIBCPP_NODEBUG = decltype(std::__to_address(std::declval<_Iter>())); static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) { return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter)); |