Skip to content

Commit cde846f

Browse files
committed
Enable SSE2 fallback for signed integers
1 parent 8cc985d commit cde846f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

include/xsimd/arch/xsimd_sse2.hpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -329,27 +329,32 @@ namespace xsimd
329329

330330
// bitwise_lshift multiple (constant)
331331
// Missing implementations are dispacthed to the `batch` overload in xsimd_api.
332-
template <class A, uint16_t... Vs>
333-
XSIMD_INLINE batch<uint16_t, A> bitwise_lshift(
334-
batch<uint16_t, A> const& self, batch_constant<uint16_t, A, Vs...> shifts, requires_arch<sse2> req) noexcept
332+
template <class T, class A, T... Vs, detail::enable_sized_integral_t<T, 2> = 0>
333+
XSIMD_INLINE batch<T, A> bitwise_lshift(
334+
batch<T, A> const& self, batch_constant<T, A, Vs...> shifts, requires_arch<sse2> req) noexcept
335335
{
336336
XSIMD_IF_CONSTEXPR(utils::all_equals(shifts))
337337
{
338338
return bitwise_lshift<shifts.get(0), A>(self, req);
339339
}
340-
constexpr auto mults = batch_constant<uint16_t, A, static_cast<uint16_t>(1u << Vs)...>();
340+
constexpr auto mults = batch_constant<T, A, static_cast<T>(1u << Vs)...>();
341341
return _mm_mullo_epi16(self, mults.as_batch());
342342
}
343343

344-
template <class A, uint8_t... Vs>
345-
XSIMD_INLINE batch<uint8_t, A> bitwise_lshift(
346-
batch<uint8_t, A> const& self, batch_constant<uint8_t, A, Vs...> shifts, requires_arch<sse2> req) noexcept
344+
template <class T, class A, T... Vs, detail::enable_sized_integral_t<T, 1> = 0>
345+
XSIMD_INLINE batch<T, A> bitwise_lshift(
346+
batch<T, A> const& self, batch_constant<T, A, Vs...> shifts, requires_arch<sse2> req) noexcept
347347
{
348+
using uint_t = typename std::make_unsigned<T>::type;
349+
348350
XSIMD_IF_CONSTEXPR(utils::all_equals(shifts))
349351
{
350352
return bitwise_lshift<shifts.get(0), A>(self, req);
351353
}
352-
return utils::bitwise_lshift_as_twice_larger<uint8_t, uint16_t>(self, shifts);
354+
return bitwise_cast<T>(
355+
utils::bitwise_lshift_as_twice_larger<uint_t, uint16_t>(
356+
bitwise_cast<uint_t>(self),
357+
batch_constant<uint_t, A, static_cast<uint_t>(Vs)...> {}));
353358
}
354359

355360
// bitwise_not

0 commit comments

Comments
 (0)