[libcxx-commits] [libcxx] [libc++] Fix endianness for algorithm mismatch (PR #93082)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 8 08:58:36 PDT 2024


================
@@ -56,6 +56,112 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro
 
 #if _LIBCPP_VECTORIZE_ALGORITHMS
 
+template <class _ValueType>
+_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __simd_vector<long long, 2>
+__reverse_vector(__simd_vector<long long, 2>& __cmp_res) {
+#  if defined(_LIBCPP_BIG_ENDIAN)
+  __cmp_res = __builtin_shufflevector(__cmp_res, __cmp_res, 1, 0);
+#  endif
+  return __cmp_res;
+}
----------------
philnik777 wrote:

I don't mean that the implementation of `__find_first_set` should be common on all platforms. I mean that it should always return the same information. You probably just have to use `countl_zero` on little endian and `countr_zero` on big endian.

https://github.com/llvm/llvm-project/pull/93082


More information about the libcxx-commits mailing list