commit 2944eda0261e8740be2c3983deb26925fa36fbb3
parent 50b19a74b2d3bc8d32a8efc1dc455cc8251593ae
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Thu, 14 Sep 2023 17:08:10 +0100
Fix subscript for nested vec
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/kfr/simd/vec.hpp b/include/kfr/simd/vec.hpp
@@ -412,12 +412,14 @@ struct alignas(internal::vec_alignment<T, N_>) vec
KFR_ENABLE_IF(dummy == 0 && !compound_type_traits<T>::is_scalar)>
KFR_MEM_INTRINSIC constexpr value_type get(size_t index) const CMT_NOEXCEPT
{
+ value_type result{};
union
{
simd_type v;
- T s[N];
+ ST s[SN];
} u{ this->v };
- return u.s[index];
+ memcpy(&result, &u.s[index * (SN / N)], sizeof(ST) * (SN / N));
+ return result;
}
template <size_t index, KFR_ENABLE_IF(index < 1024 && compound_type_traits<T>::is_scalar)>