Files
clang-p2996/libcxx/test/std/experimental/simd/simd.reference/reference_assignment.pass.cpp
Vitaly Buka 22c3d9d9a4 [libc++] Disable test which timeouts on ARM with sanitizers
Introduced with cf0f6a1460 (#70020).

https://lab.llvm.org/buildbot/#/builders/237/builds/5145
https://lab.llvm.org/buildbot/#/builders/236/builds/7004
https://lab.llvm.org/buildbot/#/builders/239/builds/4269

Sometimes it passes with Asan but it's extemly slow

```
Slowest Tests:
1388.61s: llvm-libc++-shared.cfg.in :: std/experimental/simd/simd.reference/reference_assignment.pass.cpp
309.42s:  llvm-libc++-shared.cfg.in :: std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
```
2023-10-27 14:28:28 -07:00

87 lines
2.8 KiB
C++

//===----------------------------------------------------------------------===//
//
// 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
// FIXME: Timeouts.
// UNSUPPORTED: sanitizer-new-delete
// <experimental/simd>
//
// [simd.reference]
// template<class U> reference=(U&& x) && noexcept;
//
// XFAIL: LIBCXX-AIX-FIXME
#include "../test_utils.h"
#include <experimental/simd>
namespace ex = std::experimental::parallelism_v2;
template <class T, class SimdAbi>
struct CheckSimdReferenceAssignmentHelper {
template <class U>
void operator()() const {
if constexpr (std::is_assignable_v<T&, U&&>) {
ex::simd<T, SimdAbi> origin_simd([](T i) { return i; });
for (size_t i = 0; i < origin_simd.size(); ++i) {
static_assert(noexcept(origin_simd[i] = static_cast<U>(i + 1)));
origin_simd[i] = static_cast<U>(i + 1);
assert(origin_simd[i] == static_cast<T>(std::forward<U>(i + 1)));
}
}
}
};
template <class T, class SimdAbi>
struct CheckMaskReferenceAssignmentHelper {
template <class U>
void operator()() const {
if constexpr (std::is_assignable_v<bool&, U&&>) {
ex::simd_mask<T, SimdAbi> origin_mask(true);
for (size_t i = 0; i < origin_mask.size(); ++i) {
static_assert(noexcept(origin_mask[i] = static_cast<U>(i + 1)));
origin_mask[i] = static_cast<U>(i % 2);
assert(origin_mask[i] == static_cast<T>(std::forward<U>(i % 2)));
}
}
}
};
template <class T, class SimdAbi>
struct CheckReferenceAssignmentTraitsHelper {
template <class U>
void operator()() const {
if constexpr (std::is_assignable_v<T&, U&&>)
static_assert(std::is_assignable_v<typename ex::simd<T, SimdAbi>::reference&&, U&&>);
else
static_assert(!std::is_assignable_v<typename ex::simd<T, SimdAbi>::reference&&, U&&>);
if constexpr (std::is_assignable_v<bool&, U&&>)
static_assert(std::is_assignable_v<typename ex::simd_mask<T, SimdAbi>::reference&&, U&&>);
else
static_assert(!std::is_assignable_v<typename ex::simd_mask<T, SimdAbi>::reference&&, U&&>);
}
};
template <class T, std::size_t>
struct CheckReferenceAssignment {
template <class SimdAbi>
void operator()() {
types::for_each(arithmetic_no_bool_types(), CheckSimdReferenceAssignmentHelper<T, SimdAbi>());
types::for_each(arithmetic_no_bool_types(), CheckMaskReferenceAssignmentHelper<T, SimdAbi>());
types::for_each(arithmetic_no_bool_types(), CheckReferenceAssignmentTraitsHelper<T, SimdAbi>());
}
};
int main(int, char**) {
test_all_simd_abi<CheckReferenceAssignment>();
return 0;
}