Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/xsimd/arch/xsimd_avx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,10 +1477,10 @@ namespace xsimd
{
if (std::is_signed_v<T>)
{
auto mask = (other >> (8 * sizeof(T) - 1));
auto negative = other < batch<T, A>(T(0));
auto self_pos_branch = min(std::numeric_limits<T>::max() - other, self);
auto self_neg_branch = max(std::numeric_limits<T>::min() - other, self);
return other + select(batch_bool<T, A>(mask.data), self_neg_branch, self_pos_branch);
return other + select(negative, self_neg_branch, self_pos_branch);
}
else
{
Expand Down Expand Up @@ -1728,10 +1728,10 @@ namespace xsimd
}
else if (std::is_signed_v<T>)
{
auto mask = (other >> (8 * sizeof(T) - 1));
auto negative = other < batch<T, A>(T(0));
auto self_overflow_branch = min(std::numeric_limits<T>::max() + other, self);
auto self_underflow_branch = max(std::numeric_limits<T>::min() + other, self);
return select(batch_bool<T, A>(mask.data), self_overflow_branch, self_underflow_branch) - other;
return select(negative, self_overflow_branch, self_underflow_branch) - other;
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions include/xsimd/arch/xsimd_avx512f.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,8 @@ namespace xsimd
XSIMD_INLINE unsigned char tobitset(unsigned char unpacked[N])
{
static_assert(N == 8 || N == 4 || N == 2, "valid pack size");
// The multiply gathers the N selected bits into the top N bits
// of the 8 * N bit product, so the shift is 8 * N - N.
if constexpr (N == 8)
{
uint64_t data;
Expand All @@ -1561,7 +1563,7 @@ namespace xsimd

const uint32_t magic = (0x80 + 0x4000 + 0x200000 + 0x10000000);

unsigned char res = ((data * magic) >> 24) & 0xFF;
unsigned char res = ((data * magic) >> 28) & 0xFF;
return res;
}
else if constexpr (N == 2)
Expand All @@ -1571,7 +1573,7 @@ namespace xsimd

const uint16_t magic = (0x80 + 0x4000);

unsigned char res = ((data * magic) >> 8) & 0xFF;
unsigned char res = ((data * magic) >> 14) & 0xFF;
return res;
}
}
Expand Down
4 changes: 4 additions & 0 deletions include/xsimd/arch/xsimd_common_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ namespace xsimd
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept;
template <size_t shift, class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& self, requires_arch<common>) noexcept;
template <class A, class T, class Mask>
XSIMD_INLINE batch<T, A> decr_if(batch<T, A> const& self, Mask const& mask, requires_arch<common>) noexcept;
template <class A, class T>
XSIMD_INLINE batch_bool<T, A> gt(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept;
template <class A, class T, class Mask>
XSIMD_INLINE batch<T, A> incr_if(batch<T, A> const& self, Mask const& mask, requires_arch<common>) noexcept;
template <class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
XSIMD_INLINE batch<T, A> mul(batch<T, A> const& self, batch<T, A> const& other, requires_arch<common>) noexcept;
template <class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
Expand Down
Loading