[libcxx-commits] [libcxx] [libc++] Vectorize mismatch (PR #73255)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 23 09:57:35 PST 2023


================
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_VECTORIZATION_H
+#define _LIBCPP___ALGORITHM_VECTORIZATION_H
+
+#include <__config>
+#include <__type_traits/is_floating_point.h>
+#include <__utility/integer_sequence.h>
+#include <experimental/__simd/simd.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(__OPTIMIZE_SIZE__)
+#  define _LIBCPP_VECTORIZE_ALGORITHMS 1
+#else
+#  define _LIBCPP_VECTORIZE_ALGORITHMS 0
+#endif
+
+#if _LIBCPP_VECTORIZE_ALGORITHMS && defined(__FAST_MATH__)
+#  define _LIBCPP_VECTORIZE_FLOATING_POINT_ALGORITHMS 1
+#else
+#  define _LIBCPP_VECTORIZE_FLOATING_POINT_ALGORITHMS 0
+#endif
+
+#if _LIBCPP_VECTORIZE_ALGORITHMS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+inline static const bool __fits_in_vector =
+    sizeof(_Tp) == 1 || sizeof(_Tp) == 2 || sizeof(_Tp) == 4 || sizeof(_Tp) == 8;
+
+template <class _Up>
+using __get_arithmetic_type = decltype([]<class _Tp> {
+  if constexpr (is_floating_point_v<_Tp>)
+    return _Tp{};
+  else if constexpr (constexpr auto __sz = sizeof(_Tp); __sz == 1)
----------------
ldionne wrote:

IMO feels like repeating `sizeof(_Tp)` a bunch would be easier to read.

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


More information about the libcxx-commits mailing list