Skip to content

Commit 0f44c97

Browse files
Add support for xsimd::widen on PowerPC/VSX
Related to #1179
1 parent 7cb1a1f commit 0f44c97

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/xsimd/arch/xsimd_vsx.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <type_traits>
1818

1919
#include "../types/xsimd_vsx_register.hpp"
20+
#include "./common/xsimd_common_cast.hpp"
2021

2122
#include <endian.h>
2223

@@ -873,6 +874,20 @@ namespace xsimd
873874
return vec_trunc(self.data);
874875
}
875876

877+
// widen
878+
template <class A>
879+
XSIMD_INLINE std::array<batch<double, A>, 2> widen(batch<float, A> const& x, requires_arch<vsx>) noexcept
880+
{
881+
return { batch<double, A>(vec_doublel(x.data)), batch<double, A>(vec_doubleh(x.data)) };
882+
}
883+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value>::type>
884+
XSIMD_INLINE std::array<batch<widen_t<T>, A>, 2> widen(batch<T, A> const& x, requires_arch<vsx>) noexcept
885+
{
886+
auto even = vec_mule(x.data, vec_splats(T(1))); // x0, x2, x4, x6
887+
auto odd = vec_mulo(x.data, vec_splats(T(1))); // x1, x3, x5, x7
888+
return { batch<widen_t<T>, A>(vec_mergel(even, odd)), batch<widen_t<T>, A>(vec_mergeh(even, odd)) };
889+
}
890+
876891
// zip_hi
877892
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value>::type>
878893
XSIMD_INLINE batch<T, A> zip_hi(batch<T, A> const& self, batch<T, A> const& other, requires_arch<vsx>) noexcept

0 commit comments

Comments
 (0)