Skip to content

Commit c19b1cb

Browse files
WIP
1 parent f6a2a1b commit c19b1cb

File tree

1 file changed

+11
-86
lines changed

1 file changed

+11
-86
lines changed

include/xsimd/arch/xsimd_altivec.hpp

Lines changed: 11 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -770,30 +770,18 @@ namespace xsimd
770770
return vec_rsqrt(val);
771771
}
772772

773-
#if 0
774-
775773
// select
776-
template <class A>
777-
XSIMD_INLINE batch<float, A> select(batch_bool<float, A> const& cond, batch<float, A> const& true_br, batch<float, A> const& false_br, requires_arch<altivec>) noexcept
778-
{
779-
return _mm_or_ps(_mm_and_ps(cond, true_br), _mm_andnot_ps(cond, false_br));
780-
}
781-
782-
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
774+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
783775
XSIMD_INLINE batch<T, A> select(batch_bool<T, A> const& cond, batch<T, A> const& true_br, batch<T, A> const& false_br, requires_arch<altivec>) noexcept
784776
{
785-
return _mm_or_si128(_mm_and_si128(cond, true_br), _mm_andnot_si128(cond, false_br));
777+
return vec_sel(true_br, false_br, cond);
786778
}
787-
template <class A, class T, bool... Values, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
779+
template <class A, class T, bool... Values, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
788780
XSIMD_INLINE batch<T, A> select(batch_bool_constant<T, A, Values...> const&, batch<T, A> const& true_br, batch<T, A> const& false_br, requires_arch<altivec>) noexcept
789781
{
790782
return select(batch_bool<T, A> { Values... }, true_br, false_br, altivec {});
791783
}
792-
template <class A>
793-
XSIMD_INLINE batch<double, A> select(batch_bool<double, A> const& cond, batch<double, A> const& true_br, batch<double, A> const& false_br, requires_arch<altivec>) noexcept
794-
{
795-
return _mm_or_pd(_mm_and_pd(cond, true_br), _mm_andnot_pd(cond, false_br));
796-
}
784+
#if 0
797785

798786
// shuffle
799787
template <class A, class ITy, ITy I0, ITy I1, ITy I2, ITy I3>
@@ -823,18 +811,15 @@ namespace xsimd
823811
return _mm_shuffle_pd(y, x, smask);
824812
return shuffle(x, y, mask, common {});
825813
}
814+
#endif
826815

827816
// sqrt
828817
template <class A>
829818
XSIMD_INLINE batch<float, A> sqrt(batch<float, A> const& val, requires_arch<altivec>) noexcept
830819
{
831-
return _mm_sqrt_ps(val);
832-
}
833-
template <class A>
834-
XSIMD_INLINE batch<double, A> sqrt(batch<double, A> const& val, requires_arch<altivec>) noexcept
835-
{
836-
return _mm_sqrt_pd(val);
820+
return vec_sqrt(val);
837821
}
822+
#if 0
838823

839824
// slide_left
840825
template <size_t N, class A, class T>
@@ -1014,80 +999,20 @@ namespace xsimd
1014999
transpose(reinterpret_cast<batch<double, A>*>(matrix_begin), reinterpret_cast<batch<double, A>*>(matrix_end), A {});
10151000
}
10161001

1002+
#endif
10171003
// zip_hi
1018-
template <class A>
1019-
XSIMD_INLINE batch<float, A> zip_hi(batch<float, A> const& self, batch<float, A> const& other, requires_arch<altivec>) noexcept
1020-
{
1021-
return _mm_unpackhi_ps(self, other);
1022-
}
10231004
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
10241005
XSIMD_INLINE batch<T, A> zip_hi(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
10251006
{
1026-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
1027-
{
1028-
return _mm_unpackhi_epi8(self, other);
1029-
}
1030-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
1031-
{
1032-
return _mm_unpackhi_epi16(self, other);
1033-
}
1034-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
1035-
{
1036-
return _mm_unpackhi_epi32(self, other);
1037-
}
1038-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
1039-
{
1040-
return _mm_unpackhi_epi64(self, other);
1041-
}
1042-
else
1043-
{
1044-
assert(false && "unsupported arch/op combination");
1045-
return {};
1046-
}
1047-
}
1048-
template <class A>
1049-
XSIMD_INLINE batch<double, A> zip_hi(batch<double, A> const& self, batch<double, A> const& other, requires_arch<altivec>) noexcept
1050-
{
1051-
return _mm_unpackhi_pd(self, other);
1007+
return vec_merge_hi(self, other);
10521008
}
10531009

10541010
// zip_lo
1055-
template <class A>
1056-
XSIMD_INLINE batch<float, A> zip_lo(batch<float, A> const& self, batch<float, A> const& other, requires_arch<altivec>) noexcept
1057-
{
1058-
return _mm_unpacklo_ps(self, other);
1059-
}
1060-
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
1011+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
10611012
XSIMD_INLINE batch<T, A> zip_lo(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
10621013
{
1063-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
1064-
{
1065-
return _mm_unpacklo_epi8(self, other);
1066-
}
1067-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
1068-
{
1069-
return _mm_unpacklo_epi16(self, other);
1070-
}
1071-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
1072-
{
1073-
return _mm_unpacklo_epi32(self, other);
1074-
}
1075-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
1076-
{
1077-
return _mm_unpacklo_epi64(self, other);
1078-
}
1079-
else
1080-
{
1081-
assert(false && "unsupported arch/op combination");
1082-
return {};
1083-
}
1014+
return vec_mergel(self, other);
10841015
}
1085-
template <class A>
1086-
XSIMD_INLINE batch<double, A> zip_lo(batch<double, A> const& self, batch<double, A> const& other, requires_arch<altivec>) noexcept
1087-
{
1088-
return _mm_unpacklo_pd(self, other);
1089-
}
1090-
#endif
10911016
}
10921017
}
10931018

0 commit comments

Comments
 (0)