Skip to content

Commit 67d47f2

Browse files
amysparkserge-sans-paille
authored andcommitted
Implement slides for NEON
1 parent c7567bb commit 67d47f2

File tree

3 files changed

+66
-7
lines changed

3 files changed

+66
-7
lines changed

Diff for: include/xsimd/arch/xsimd_neon.hpp

+66
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,72 @@ namespace xsimd
24272427
{
24282428
return !(arg == arg);
24292429
}
2430+
2431+
// slide_left
2432+
namespace detail
2433+
{
2434+
template <size_t N>
2435+
struct slider_left
2436+
{
2437+
template <class A, class T>
2438+
inline batch<T, A> operator()(batch<T, A> const& x, requires_arch<neon>) noexcept
2439+
{
2440+
const auto left = vdupq_n_u8(0);
2441+
const auto right = bitwise_cast<batch<uint8_t, A>>(x).data;
2442+
const batch<uint8_t, A> res(vextq_u8(left, right, 16 - N));
2443+
return bitwise_cast<batch<T, A>>(res);
2444+
}
2445+
};
2446+
2447+
template <>
2448+
struct slider_left<0>
2449+
{
2450+
template <class A, class T>
2451+
inline batch<T, A> operator()(batch<T, A> const& x, requires_arch<neon>) noexcept
2452+
{
2453+
return x;
2454+
}
2455+
};
2456+
} // namespace detail
2457+
2458+
template <size_t N, class A, class T>
2459+
inline batch<T, A> slide_left(batch<T, A> const& x, requires_arch<neon>) noexcept
2460+
{
2461+
return detail::slider_left<N> {}(x, A {});
2462+
}
2463+
2464+
// slide_right
2465+
namespace detail
2466+
{
2467+
template <size_t N>
2468+
struct slider_right
2469+
{
2470+
template <class A, class T>
2471+
inline batch<T, A> operator()(batch<T, A> const& x, requires_arch<neon>) noexcept
2472+
{
2473+
const auto left = bitwise_cast<batch<uint8_t, A>>(x).data;
2474+
const auto right = vdupq_n_u8(0);
2475+
const batch<uint8_t, A> res(vextq_u8(left, right, N));
2476+
return bitwise_cast<batch<T, A>>(res);
2477+
}
2478+
};
2479+
2480+
template <>
2481+
struct slider_right<16>
2482+
{
2483+
template <class A, class T>
2484+
inline batch<T, A> operator()(batch<T, A> const&, requires_arch<neon>) noexcept
2485+
{
2486+
return batch<T, A> {};
2487+
}
2488+
};
2489+
} // namespace detail
2490+
2491+
template <size_t N, class A, class T>
2492+
inline batch<T, A> slide_right(batch<T, A> const& x, requires_arch<neon>) noexcept
2493+
{
2494+
return detail::slider_right<N> {}(x, A {});
2495+
}
24302496
}
24312497

24322498
template <class batch_type, typename batch_type::value_type... Values>

Diff for: include/xsimd/types/xsimd_api.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -1664,8 +1664,6 @@ namespace xsimd
16641664
return kernel::sincos<A>(x, A {});
16651665
}
16661666

1667-
#if XSIMD_WITH_SSE2
1668-
16691667
/**
16701668
* @ingroup batch_data_transfer
16711669
*
@@ -1700,8 +1698,6 @@ namespace xsimd
17001698
return kernel::slide_right<N, A>(x, A {});
17011699
}
17021700

1703-
#endif
1704-
17051701
/**
17061702
* @ingroup batch_math
17071703
*

Diff for: test/test_shuffle.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ namespace
166166
};
167167
}
168168

169-
#if XSIMD_WITH_SSE2
170-
171169
template <class B>
172170
class slide_test : public testing::Test, init_slide_base<typename B::value_type, B::size>
173171
{
@@ -262,4 +260,3 @@ TYPED_TEST(slide_test, slide_right)
262260
this->slide_right();
263261
}
264262
#endif
265-
#endif

0 commit comments

Comments
 (0)