@@ -347,23 +347,40 @@ namespace xsimd
347347 }
348348
349349 // bitwise_lshift multiple (constant)
350- template <class A , class T , T... Vs, detail::enable_integral_t <T > = 0 >
350+ template <class T , class A , T... Vs, detail::enable_sized_integral_t <T, 8 > = 0 >
351351 XSIMD_INLINE batch<T, A> bitwise_lshift (
352352 batch<T, A> const & self, batch_constant<T, A, Vs...> shifts, requires_arch<avx2> req) noexcept
353353 {
354- XSIMD_IF_CONSTEXPR (std::is_same<T, uint8_t >::value)
355- {
356- return utils::bitwise_lshift_as_twice_larger<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- }
354+ return bitwise_lshift (self, shifts.as_batch (), req);
355+ }
356+
357+ template <class T , class A , T... Vs, detail::enable_sized_integral_t <T, 4 > = 0 >
358+ XSIMD_INLINE batch<T, A> bitwise_lshift (
359+ batch<T, A> const & self, batch_constant<T, A, Vs...> shifts, requires_arch<avx2> req) noexcept
360+ {
361+ return bitwise_lshift (self, shifts.as_batch (), req);
362+ }
363+
364+ template <class T , class A , T... Vs, detail::enable_sized_integral_t <T, 2 > = 0 >
365+ XSIMD_INLINE batch<T, A> bitwise_lshift (
366+ batch<T, A> const & self, batch_constant<T, A, Vs...> shifts, requires_arch<avx2>) noexcept
367+ {
368+ using uint_t = typename std::make_unsigned<T>::type;
369+ return bitwise_cast<T>(
370+ utils::bitwise_lshift_as_twice_larger<uint_t , uint32_t >(
371+ bitwise_cast<uint_t >(self),
372+ bitwise_cast<uint_t >(shifts)));
373+ }
374+
375+ template <class T , class A , T... Vs, detail::enable_sized_integral_t <T, 1 > = 0 >
376+ XSIMD_INLINE batch<T, A> bitwise_lshift (
377+ batch<T, A> const & self, batch_constant<T, A, Vs...> shifts, requires_arch<avx2>) noexcept
378+ {
379+ using uint_t = typename std::make_unsigned<T>::type;
380+ return bitwise_cast<T>(
381+ utils::bitwise_lshift_as_twice_larger<uint_t , uint16_t >(
382+ bitwise_cast<uint_t >(self),
383+ bitwise_cast<uint_t >(shifts)));
367384 }
368385
369386 // bitwise_rshift
0 commit comments