[libcxx-commits] [libcxx] [libc++] <experimental/simd> Add load constructor for class simd/simd_mask (PR #76610)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Dec 30 01:51:47 PST 2023
================
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+// <experimental/simd>
+//
+// [simd.class]
+// template<class U, class Flags> simd(const U* mem, Flags);
+
+#include "../test_utils.h"
+
+namespace ex = std::experimental::parallelism_v2;
+
+template <class T, class SimdAbi, std::size_t array_size>
+struct ElementAlignedLoadCtorHelper {
+ template <class U>
+ void operator()() const {
+ constexpr std::size_t alignas_size = alignof(U);
+ alignas(alignas_size) U buffer[array_size];
+ for (size_t i = 0; i < array_size; ++i)
+ buffer[i] = static_cast<U>(i);
+ ex::simd<T, SimdAbi> origin_simd(buffer, ex::element_aligned_tag());
+ assert_simd_values_equal(origin_simd, buffer);
+ }
+};
+
+template <class T, class SimdAbi, std::size_t array_size>
+struct VectorAlignedLoadCtorHelper {
+ template <class U>
+ void operator()() const {
+ constexpr std::size_t alignas_size = ex::memory_alignment_v<ex::simd<T, SimdAbi>, U>;
+ alignas(alignas_size) U buffer[array_size];
----------------
philnik777 wrote:
```suggestion
alignas([alignas_size](ex::memory_alignment_v<ex::simd<T, SimdAbi>, U>)) U buffer[array_size];
```
Same for the other ones.
https://github.com/llvm/llvm-project/pull/76610
More information about the libcxx-commits
mailing list