//===----------------------------------------------------------------------===// // // 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 // XFAIL: target=powerpc{{.*}}le-unknown-linux-gnu // // // [simd.class] // template simd(U&& value) noexcept; #include #include #include "../test_utils.h" namespace ex = std::experimental::parallelism_v2; template struct BroadCastHelper { const std::array& expected_value; BroadCastHelper(const std::array& value) : expected_value(value) {} template void operator()() const { if constexpr (is_non_narrowing_convertible_v) { ex::simd simd_broadcast_from_vectorizable_type(static_cast(3)); assert_simd_values_equal(simd_broadcast_from_vectorizable_type, expected_value); } } }; template struct CheckSimdBroadcastCtorFromVectorizedType { template void operator()() { constexpr std::size_t array_size = ex::simd_size_v; std::array expected_value; std::fill(expected_value.begin(), expected_value.end(), 3); types::for_each(simd_test_types(), BroadCastHelper(expected_value)); } }; template class implicit_type { T val; public: implicit_type(T v) : val(v) {} operator T() const { return val; } }; template struct CheckSimdBroadcastCtor { template void operator()() { constexpr std::size_t array_size = ex::simd_size_v; std::array expected_value; std::fill(expected_value.begin(), expected_value.end(), 3); implicit_type implicit_convert_to_3(3); ex::simd simd_broadcast_from_implicit_type(std::move(implicit_convert_to_3)); assert_simd_values_equal(simd_broadcast_from_implicit_type, expected_value); ex::simd simd_broadcast_from_int(3); assert_simd_values_equal(simd_broadcast_from_int, expected_value); if constexpr (std::is_unsigned_v) { ex::simd simd_broadcast_from_uint(3u); assert_simd_values_equal(simd_broadcast_from_uint, expected_value); } } }; template class no_implicit_type { T val; public: no_implicit_type(T v) : val(v) {} }; template , class = void> struct has_broadcast_ctor : std::false_type {}; template struct has_broadcast_ctor(std::declval()))>> : std::true_type {}; template struct CheckBroadcastCtorTraitsHelper { template void operator()() const { if constexpr (std::is_same_v) static_assert(has_broadcast_ctor::value); else if constexpr (std::is_same_v && std::is_unsigned_v) static_assert(has_broadcast_ctor::value); else if constexpr (is_non_narrowing_convertible_v) static_assert(has_broadcast_ctor::value); else static_assert(!has_broadcast_ctor::value); } }; template struct CheckBroadcastCtorTraits { template void operator()() { types::for_each(simd_test_types(), CheckBroadcastCtorTraitsHelper()); static_assert(!has_broadcast_ctor, T, SimdAbi>::value); static_assert(has_broadcast_ctor, T, SimdAbi>::value); } }; int main(int, char**) { test_all_simd_abi(); test_all_simd_abi(); test_all_simd_abi(); return 0; }