diff --git a/include/xsimd/arch/xsimd_sse2.hpp b/include/xsimd/arch/xsimd_sse2.hpp index 17633fd68..ec173f7c9 100644 --- a/include/xsimd/arch/xsimd_sse2.hpp +++ b/include/xsimd/arch/xsimd_sse2.hpp @@ -1237,22 +1237,7 @@ namespace xsimd batch acc3 = min(acc2, step3); return acc3.get(0); } - // TODO: move this in xsimd_generic - namespace detail - { - template ::value, void>::type> - inline T hadd_default(batch const& self, requires_arch) noexcept - { - alignas(A::alignment()) T buffer[batch::size]; - self.store_aligned(buffer); - T res = 0; - for (T val : buffer) - { - res += val; - } - return res; - } - } + template ::value, void>::type> inline T reduce_add(batch const& self, requires_arch) noexcept { @@ -1280,7 +1265,7 @@ namespace xsimd } else { - return detail::hadd_default(self, A {}); + return hadd(self, generic {}); } } template @@ -1381,28 +1366,6 @@ namespace xsimd // sadd - // TODO: move this in xsimd_generic - namespace detail - { - template ::value, void>::type> - inline batch sadd_default(batch const& self, batch const& other, requires_arch) noexcept - { - if (std::is_signed::value) - { - auto mask = (other >> (8 * sizeof(T) - 1)); - auto self_pos_branch = min(std::numeric_limits::max() - other, self); - auto self_neg_branch = max(std::numeric_limits::min() - other, self); - return other + select(batch_bool(mask.data), self_neg_branch, self_pos_branch); - } - else - { - const auto diffmax = std::numeric_limits::max() - self; - const auto mindiff = min(diffmax, other); - return self + mindiff; - } - } - } - template ::value, void>::type> inline batch sadd(batch const& self, batch const& other, requires_arch) noexcept { @@ -1418,7 +1381,7 @@ namespace xsimd } else { - return detail::sadd_default(self, other, A {}); + return sadd(self, other, generic {}); } } else @@ -1433,7 +1396,7 @@ namespace xsimd } else { - return detail::sadd_default(self, other, A {}); + return sadd(self, other, generic {}); } } } @@ -1495,23 +1458,6 @@ namespace xsimd } // ssub - // TODO: move this in xsimd_generic - namespace detail - { - template ::value, void>::type> - inline batch ssub_default(batch const& self, batch const& other, requires_arch) noexcept - { - if (std::is_signed::value) - { - return sadd(self, -other); - } - else - { - const auto diff = min(self, other); - return self - diff; - } - } - } template ::value, void>::type> inline batch ssub(batch const& self, batch const& other, requires_arch) noexcept @@ -1528,7 +1474,7 @@ namespace xsimd } else { - return detail::ssub_default(self, other, A {}); + return ssub(self, other, generic {}); } } else @@ -1543,7 +1489,7 @@ namespace xsimd } else { - return detail::ssub_default(self, other, A {}); + return ssub(self, other, generic {}); } } }