forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] <experimental/simd> Add ++/-- operators for simd reference (l…
- Loading branch information
1 parent
cbd3068
commit 812ae91
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
libcxx/test/std/experimental/simd/simd.reference/reference_unary.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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.reference] | ||
// reference operator++() && noexcept; | ||
// value_type operator++(int) && noexcept; | ||
// reference operator--() && noexcept; | ||
// value_type operator--(int) && noexcept; | ||
|
||
#include "../test_utils.h" | ||
#include <experimental/simd> | ||
|
||
namespace ex = std::experimental::parallelism_v2; | ||
|
||
template <class T, std::size_t> | ||
struct CheckSimdReferenceUnaryOperators { | ||
template <class SimdAbi> | ||
void operator()() const { | ||
ex::simd<T, SimdAbi> origin_simd(static_cast<T>(3)); | ||
static_assert(noexcept(++origin_simd[0])); | ||
assert(((T)(++origin_simd[0]) == static_cast<T>(4)) && ((T)origin_simd[0] == static_cast<T>(4))); | ||
static_assert(noexcept(origin_simd[0]++)); | ||
assert(((T)(origin_simd[0]++) == static_cast<T>(4)) && ((T)origin_simd[0] == static_cast<T>(5))); | ||
static_assert(noexcept(--origin_simd[0])); | ||
assert(((T)(--origin_simd[0]) == static_cast<T>(4)) && ((T)origin_simd[0] == static_cast<T>(4))); | ||
static_assert(noexcept(origin_simd[0]--)); | ||
assert(((T)(origin_simd[0]--) == static_cast<T>(4)) && ((T)origin_simd[0] == static_cast<T>(3))); | ||
} | ||
}; | ||
|
||
int main(int, char**) { | ||
test_all_simd_abi<CheckSimdReferenceUnaryOperators>(); | ||
return 0; | ||
} |