Skip to content

Commit c89a5ea

Browse files
committed
Fix Avx2
1 parent 1cd12f9 commit c89a5ea

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

include/xsimd/arch/xsimd_avx2.hpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,23 @@ namespace xsimd
347347
}
348348

349349
// bitwise_lshift multiple (constant)
350-
template <class A, uint16_t... Vs>
351-
XSIMD_INLINE batch<uint16_t, A> bitwise_lshift(
352-
batch<uint16_t, A> const& self, batch_constant<uint16_t, A, Vs...> shifts, requires_arch<avx2>) noexcept
350+
template <class A, class T, T... Vs, detail::enable_integral_t<T> = 0>
351+
XSIMD_INLINE batch<T, A> bitwise_lshift(
352+
batch<T, A> const& self, batch_constant<T, A, Vs...> shifts, requires_arch<avx2> req) noexcept
353353
{
354-
constexpr auto mults = batch_constant<uint16_t, A, static_cast<uint16_t>(1u << Vs)...>();
355-
return _mm256_mullo_epi16(self, mults.as_batch());
356-
}
357-
358-
template <class A, uint8_t... Vs>
359-
XSIMD_INLINE batch<uint8_t, A> bitwise_lshift(
360-
batch<uint8_t, A> const& self, batch_constant<uint8_t, A, Vs...> shifts, requires_arch<avx2> req) noexcept
361-
{
362-
return utils::bitwise_lshift_as_twice_larger<uint8_t, uint16_t>(self, shifts);
354+
XSIMD_IF_CONSTEXPR(std::is_same<T, uint8_t>::value)
355+
{
356+
return utils::bitwise_lshift_as_twice_larger<uint8_t, uint16_t>(self, shifts);
357+
}
358+
XSIMD_IF_CONSTEXPR(std::is_same<T, uint16_t>::value)
359+
{
360+
constexpr auto mults = batch_constant<uint16_t, A, static_cast<uint16_t>(1u << Vs)...>();
361+
return _mm256_mullo_epi16(self, mults.as_batch());
362+
}
363+
else
364+
{
365+
return bitwise_lshift(self, shifts.as_batch(), req);
366+
}
363367
}
364368

365369
// bitwise_rshift

0 commit comments

Comments
 (0)