Skip to content

Commit d6150b8

Browse files
Support immediate version of btitwise shift on arm
1 parent e392354 commit d6150b8

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

include/xsimd/arch/xsimd_neon.hpp

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,6 +2314,55 @@ namespace xsimd
23142314
return vshlq_s64(lhs, rhs);
23152315
}
23162316

2317+
// immediate variant
2318+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 1> = 0>
2319+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2320+
{
2321+
return vshlq_n_u8(x, shift);
2322+
}
2323+
2324+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 1> = 0>
2325+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2326+
{
2327+
return vshlq_n_s8(x, shift);
2328+
}
2329+
2330+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 2> = 0>
2331+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2332+
{
2333+
return vshlq_n_u16(x, shift);
2334+
}
2335+
2336+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 2> = 0>
2337+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2338+
{
2339+
return vshlq_n_s16(x, shift);
2340+
}
2341+
2342+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 4> = 0>
2343+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2344+
{
2345+
return vshlq_n_u32(x, shift);
2346+
}
2347+
2348+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 4> = 0>
2349+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2350+
{
2351+
return vshlq_n_s32(x, shift);
2352+
}
2353+
2354+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 8> = 0>
2355+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2356+
{
2357+
return vshlq_n_u64(x, shift);
2358+
}
2359+
2360+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 8> = 0>
2361+
XSIMD_INLINE batch<T, A> bitwise_lshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2362+
{
2363+
return vshlq_n_s64(x, shift);
2364+
}
2365+
23172366
/******************
23182367
* bitwise_rshift *
23192368
******************/
@@ -2489,6 +2538,55 @@ namespace xsimd
24892538
return vshlq_s32(lhs, vnegq_s32(rhs));
24902539
}
24912540

2541+
// immediate variant
2542+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 1> = 0>
2543+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2544+
{
2545+
return vshrq_n_u8(x, shift);
2546+
}
2547+
2548+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 1> = 0>
2549+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2550+
{
2551+
return vshrq_n_s8(x, shift);
2552+
}
2553+
2554+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 2> = 0>
2555+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2556+
{
2557+
return vshrq_n_u16(x, shift);
2558+
}
2559+
2560+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 2> = 0>
2561+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2562+
{
2563+
return vshrq_n_s16(x, shift);
2564+
}
2565+
2566+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 4> = 0>
2567+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2568+
{
2569+
return vshrq_n_u32(x, shift);
2570+
}
2571+
2572+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 4> = 0>
2573+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2574+
{
2575+
return vshrq_n_s32(x, shift);
2576+
}
2577+
2578+
template <size_t shift, class A, class T, detail::enable_sized_unsigned_t<T, 8> = 0>
2579+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2580+
{
2581+
return vshrq_n_u64(x, shift);
2582+
}
2583+
2584+
template <size_t shift, class A, class T, detail::enable_sized_signed_t<T, 8> = 0>
2585+
XSIMD_INLINE batch<T, A> bitwise_rshift(batch<T, A> const& x, requires_arch<neon>) noexcept
2586+
{
2587+
return vshrq_n_s64(x, shift);
2588+
}
2589+
24922590
// first
24932591
template <class A>
24942592
XSIMD_INLINE float first(batch<float, A> const& self, requires_arch<neon>) noexcept

0 commit comments

Comments
 (0)