Skip to content

Commit bd966af

Browse files
Add first support for neon 32 and 64 bit
1 parent 0576683 commit bd966af

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

include/xsimd/arch/xsimd_neon.hpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,61 @@ namespace xsimd
24552455
return vshlq_s32(lhs, vnegq_s32(rhs));
24562456
}
24572457

2458+
// first
2459+
template <class A>
2460+
XSIMD_INLINE float first(batch<float, A> const& self, requires_arch<neon>) noexcept
2461+
{
2462+
return vgetq_lane_f32(self, 0);
2463+
}
2464+
2465+
template <class A, class T, detail::enable_sized_unsigned_t<T, 1> = 0>
2466+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2467+
{
2468+
return vgetq_lane_u8(val, 0);
2469+
}
2470+
2471+
template <class A, class T, detail::enable_sized_signed_t<T, 1> = 0>
2472+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2473+
{
2474+
return vgetq_lane_s8(val, 0);
2475+
}
2476+
2477+
template <class A, class T, detail::enable_sized_unsigned_t<T, 2> = 0>
2478+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2479+
{
2480+
return vgetq_lane_u16(val, 0);
2481+
}
2482+
2483+
template <class A, class T, detail::enable_sized_signed_t<T, 2> = 0>
2484+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2485+
{
2486+
return vgetq_lane_s16(val, 0);
2487+
}
2488+
2489+
template <class A, class T, detail::enable_sized_unsigned_t<T, 4> = 0>
2490+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2491+
{
2492+
return vgetq_lane_u32(val, 0);
2493+
}
2494+
2495+
template <class A, class T, detail::enable_sized_signed_t<T, 4> = 0>
2496+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2497+
{
2498+
return vgetq_lane_s32(val, 0);
2499+
}
2500+
2501+
template <class A, class T, detail::enable_sized_unsigned_t<T, 8> = 0>
2502+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2503+
{
2504+
return vgetq_lane_u64(val, 0);
2505+
}
2506+
2507+
template <class A, class T, detail::enable_sized_signed_t<T, 8> = 0>
2508+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2509+
{
2510+
return vgetq_lane_s64(val, 0);
2511+
}
2512+
24582513
// Overloads of bitwise shifts accepting two batches of uint64/int64 are not available with ARMv7
24592514

24602515
/*******

include/xsimd/arch/xsimd_neon64.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ namespace xsimd
2828
{
2929
using namespace types;
3030

31+
// first
32+
template <class A>
33+
XSIMD_INLINE double first(batch<double, A> const& self, requires_arch<neon64>) noexcept
34+
{
35+
return vgetq_lane_f64(self, 0);
36+
}
37+
3138
/*******
3239
* all *
3340
*******/

0 commit comments

Comments
 (0)