timshen created this revision.
timshen added reviewers: mclow.lists, EricWF.
Herald added a subscriber: sanjoy.

The cleanup patch adds sevreal TODOs for the following unimplemented
features:
*) aligned load
*) simd<> version of <cmath> functions

This patch declares the completion of my implementation of
<experimental/simd>.


https://reviews.llvm.org/D41845

Files:
  libcxx/include/experimental/simd

Index: libcxx/include/experimental/simd
===================================================================
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -1522,11 +1522,11 @@
   return __m.size();
 }
 
-bool all_of(bool __v) noexcept { return __v; }
-bool any_of(bool __v) noexcept { return __v; }
-bool none_of(bool __v) noexcept { return !__v; }
+bool all_of(bool __val) noexcept { return __val; }
+bool any_of(bool __val) noexcept { return __val; }
+bool none_of(bool __val) noexcept { return !__val; }
 bool some_of(bool) noexcept { return false; }
-int popcount(bool __v) noexcept { return __v; }
+int popcount(bool __val) noexcept { return __val; }
 int find_first_set(bool) noexcept { return 0; }
 int find_last_set(bool) noexcept { return 0; }
 
@@ -1681,9 +1681,9 @@
   template <class _Up,
             class = typename std::enable_if<__can_broadcast<_Up>()>::type>
   simd(_Up&& __rv) {
-    auto __v = static_cast<_Tp>(__rv);
+    auto __val = static_cast<_Tp>(__rv);
     for (size_t __i = 0; __i < size(); __i++) {
-      (*this)[__i] = __v;
+      (*this)[__i] = __val;
     }
   }
 
@@ -1987,9 +1987,9 @@
   simd_mask() = default;
 
   // broadcast constructor
-  explicit simd_mask(value_type __value) noexcept {
+  explicit simd_mask(value_type __val) noexcept {
     for (size_t __i = 0; __i < size(); __i++) {
-      (*this)[__i] = __value;
+      (*this)[__i] = __val;
     }
   }
 
@@ -2009,6 +2009,7 @@
   template <class _Flags, class = typename std::enable_if<
                               is_simd_flag_type<_Flags>::value>::type>
   simd_mask(const value_type* __buffer, _Flags) {
+    // TODO: optimize for overaligned flags
     for (size_t __i = 0; __i < size(); __i++) {
       (*this)[__i] = __buffer[__i];
     }
@@ -2024,6 +2025,7 @@
   template <class _Flags>
   typename std::enable_if<is_simd_flag_type<_Flags>::value>::type
   copy_to(value_type* __buffer, _Flags) const {
+    // TODO: optimize for overaligned flags
     for (size_t __i = 0; __i < size(); __i++) {
       __buffer[__i] = (*this)[__i];
     }
@@ -2093,6 +2095,7 @@
 template <class _Tp, class _Abi, class _Up, class _Flags>
 void __mask_copy_to(const simd<_Tp, _Abi>& __v, const simd_mask<_Tp, _Abi>& __m,
                     _Up* __buffer, _Flags) {
+  // TODO: optimize for overaligned flags
   for (size_t __i = 0; __i < __v.size(); __i++) {
     if (__m[__i]) {
       __buffer[__i] = static_cast<_Up>(__v[__i]);
@@ -2103,17 +2106,18 @@
 template <class _Tp, class _Abi, class _Up, class _Flags>
 void __mask_copy_to(const simd_mask<_Tp, _Abi>& __v,
                     const simd_mask<_Tp, _Abi>& __m, _Up* __buffer, _Flags) {
+  // TODO: optimize based on bool's bit pattern.
   for (size_t __i = 0; __i < __v.size(); __i++) {
     if (__m[__i]) {
       __buffer[__i] = static_cast<_Up>(__v[__i]);
     }
   }
 }
 
 template <class _Tp, class _Up, class _Flags>
-void __mask_copy_to(_Tp __v, bool __m, _Up* __buffer, _Flags) {
+void __mask_copy_to(_Tp __val, bool __m, _Up* __buffer, _Flags) {
   if (__m) {
-    *__buffer = static_cast<_Up>(__v);
+    *__buffer = static_cast<_Up>(__val);
   }
 }
 
@@ -2141,9 +2145,9 @@
 }
 
 template <class _Tp, class _Up, class _Flags>
-void __mask_copy_from(_Tp& __v, bool __m, const _Up* __buffer, _Flags) {
+void __mask_copy_from(_Tp& __val, bool __m, const _Up* __buffer, _Flags) {
   if (__m) {
-    __v = static_cast<_Tp>(*__buffer);
+    __val = static_cast<_Tp>(*__buffer);
   }
 }
 
@@ -2493,6 +2497,8 @@
       __w.__v_, __w.__m_));
 }
 
+// TODO: Implement <cmath> functions for simd.
+
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
 #endif /* _LIBCPP_EXPERIMENTAL_SIMD */
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to