Skip to content

Commit bd9c72a

Browse files
committed
Add 8bit lshift avx2 constant
1 parent a186c03 commit bd9c72a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/xsimd/arch/xsimd_avx2.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ namespace xsimd
179179
{
180180
constexpr auto bits = std::numeric_limits<T>::digits + std::numeric_limits<T>::is_signed;
181181
static_assert(shift < bits, "Shift must be less than the number of bits in T");
182+
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
183+
{
184+
constexpr uint8_t mask8 = static_cast<uint8_t>(~0u << shift);
185+
__m256i const mask = _mm256_set1_epi8(mask8);
186+
return _mm256_and_si256(_mm256_slli_epi16(self, shift), mask);
187+
}
182188
XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
183189
{
184190
return _mm256_slli_epi16(self, shift);
@@ -191,10 +197,6 @@ namespace xsimd
191197
{
192198
return _mm256_slli_epi64(self, shift);
193199
}
194-
else
195-
{
196-
return bitwise_lshift<shift>(self, avx {});
197-
}
198200
}
199201

200202
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value>::type>

0 commit comments

Comments
 (0)