Skip to content

Commit f6a2a1b

Browse files
WIP
1 parent fc7d26f commit f6a2a1b

File tree

1 file changed

+14
-46
lines changed

1 file changed

+14
-46
lines changed

include/xsimd/arch/xsimd_altivec.hpp

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -95,45 +95,21 @@ namespace xsimd
9595
return vec_any_ne(self, vec_xor(self, self));
9696
}
9797

98-
#if 0
9998
// avgr
100-
template <class A, class T, class = typename std::enable_if<std::is_unsigned<T>::value, void>::type>
99+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
101100
XSIMD_INLINE batch<T, A> avgr(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
102101
{
103-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
104-
{
105-
return _mm_avg_epu8(self, other);
106-
}
107-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
108-
{
109-
return _mm_avg_epu16(self, other);
110-
}
111-
else
112-
{
113-
return avgr(self, other, common {});
114-
}
102+
return vec_avg(self, other);
115103
}
116104

117105
// avg
118-
template <class A, class T, class = typename std::enable_if<std::is_unsigned<T>::value, void>::type>
106+
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
119107
XSIMD_INLINE batch<T, A> avg(batch<T, A> const& self, batch<T, A> const& other, requires_arch<altivec>) noexcept
120108
{
121-
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
122-
{
123-
auto adj = ((self ^ other) << 7) >> 7;
124-
return avgr(self, other, A {}) - adj;
125-
}
126-
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
127-
{
128-
auto adj = ((self ^ other) << 15) >> 15;
129-
return avgr(self, other, A {}) - adj;
130-
}
131-
else
132-
{
133-
return avg(self, other, common {});
134-
}
109+
constexpr auto nbit = 8 * sizeof(T) - 1;
110+
constexpr auto adj = ((self ^ other) << nbit) >> nbit;
111+
return avgr(self, other, A {}) - adj;
135112
}
136-
#endif
137113

138114
// batch_bool_cast
139115
template <class A, class T_out, class T_in>
@@ -482,20 +458,14 @@ namespace xsimd
482458
tmp0 = _mm_movelh_ps(tmp0, tmp1);
483459
return _mm_add_ps(tmp0, tmp2);
484460
}
485-
template <class A>
486-
XSIMD_INLINE batch<double, A> haddp(batch<double, A> const* row, requires_arch<altivec>) noexcept
487-
{
488-
return _mm_add_pd(_mm_unpacklo_pd(row[0], row[1]),
489-
_mm_unpackhi_pd(row[0], row[1]));
490-
}
461+
#endif
491462

492463
// incr_if
493464
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
494465
XSIMD_INLINE batch<T, A> incr_if(batch<T, A> const& self, batch_bool<T, A> const& mask, requires_arch<altivec>) noexcept
495466
{
496467
return self - batch<T, A>(mask.data);
497468
}
498-
#endif
499469

500470
// insert
501471
template <class A, class T, size_t I, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
@@ -522,7 +492,7 @@ namespace xsimd
522492
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
523493
XSIMD_INLINE batch<T, A> load_unaligned(T const* mem, convert<T>, requires_arch<altivec>) noexcept
524494
{
525-
return *(typename batch<T, A>::register_type)mem;
495+
return batch<T, A>(*(typename batch<T, A>::register_type)mem);
526496
}
527497

528498
#if 0
@@ -791,19 +761,17 @@ namespace xsimd
791761
batch<T, A> acc3 = min(acc2, step3);
792762
return first(acc3, A {});
793763
}
764+
#endif
794765

795766
// rsqrt
796767
template <class A>
797768
XSIMD_INLINE batch<float, A> rsqrt(batch<float, A> const& val, requires_arch<altivec>) noexcept
798769
{
799-
return _mm_rsqrt_ps(val);
800-
}
801-
template <class A>
802-
XSIMD_INLINE batch<double, A> rsqrt(batch<double, A> const& val, requires_arch<altivec>) noexcept
803-
{
804-
return _mm_cvtps_pd(_mm_rsqrt_ps(_mm_cvtpd_ps(val)));
770+
return vec_rsqrt(val);
805771
}
806772

773+
#if 0
774+
807775
// select
808776
template <class A>
809777
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
@@ -917,14 +885,14 @@ namespace xsimd
917885
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
918886
XSIMD_INLINE void store_aligned(T* mem, batch<T, A> const& self, requires_arch<altivec>) noexcept
919887
{
920-
return vec_st(self, 0, mem);
888+
return vec_st(self.data, 0, mem);
921889
}
922890

923891
// store_unaligned
924892
template <class A, class T, class = typename std::enable_if<std::is_scalar<T>::value, void>::type>
925893
XSIMD_INLINE void store_unaligned(T* mem, batch<T, A> const& self, requires_arch<altivec>) noexcept
926894
{
927-
*(typename batch<T, A>::register_type)mem = self;
895+
*(typename batch<T, A>::register_type)mem = self.data;
928896
}
929897

930898
// sub

0 commit comments

Comments
 (0)