Skip to content

Commit 112ac7d

Browse files
Improve swizzle for arm32 - [u]int32
1 parent 9505dc4 commit 112ac7d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

include/xsimd/arch/xsimd_neon.hpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,6 +2914,54 @@ namespace xsimd
29142914
{
29152915
return vreinterpretq_s64_u64(swizzle(vreinterpretq_u64_s64(self), mask, A {}));
29162916
}
2917+
2918+
template <class A, uint32_t V0, uint32_t V1, uint32_t V2, uint32_t V3>
2919+
XSIMD_INLINE batch<uint32_t, A> swizzle(batch<uint32_t, A> const& self,
2920+
batch_constant<uint32_t, A, V0, V1, V2, V3> mask,
2921+
requires_arch<neon>) noexcept
2922+
{
2923+
constexpr bool is_identity = detail::is_identity(mask);
2924+
constexpr bool is_dup_lo = detail::is_dup_lo(mask);
2925+
constexpr bool is_dup_hi = detail::is_dup_hi(mask);
2926+
2927+
XSIMD_IF_CONSTEXPR(is_identity)
2928+
{
2929+
return self;
2930+
}
2931+
XSIMD_IF_CONSTEXPR(is_dup_lo)
2932+
{
2933+
XSIMD_IF_CONSTEXPR(V0 == 0 && V1 == 1)
2934+
{
2935+
return vreinterpretq_u32_u64(vdupq_lane_u64(vget_low_u64(vreinterpretq_u64_u32(self)), 0));
2936+
}
2937+
else
2938+
{
2939+
return vreinterpretq_u32_u64(vdupq_lane_u64(vreinterpret_u64_u32(vrev64_u32(vget_low_u32(self))), 0));
2940+
}
2941+
}
2942+
XSIMD_IF_CONSTEXPR(is_dup_hi)
2943+
{
2944+
XSIMD_IF_CONSTEXPR(V0 == 2 && V1 == 3)
2945+
{
2946+
return vreinterpretq_u32_u64(vdupq_lane_u64(vget_high_u64(vreinterpretq_u64_u32(self)), 0));
2947+
}
2948+
else
2949+
{
2950+
return vreinterpretq_u32_u64(vdupq_lane_u64(vreinterpret_u64_u32(vrev64_u32(vget_high_u32(self))), 0));
2951+
}
2952+
}
2953+
std::array<uint32_t, 4> data;
2954+
self.store_aligned(data.data());
2955+
return set(batch<uint32_t, A>(), A(), data[V0], data[V1], data[V2], data[V3]);
2956+
}
2957+
2958+
template <class A, uint32_t V0, uint32_t V1>
2959+
XSIMD_INLINE batch<int32_t, A> swizzle(batch<int32_t, A> const& self,
2960+
batch_constant<int32_t, A, V0, V1> mask,
2961+
requires_arch<neon>) noexcept
2962+
{
2963+
return vreinterpretq_s32_u32(swizzle(vreinterpretq_u32_s32(self), mask, A {}));
2964+
}
29172965
}
29182966

29192967
}

0 commit comments

Comments
 (0)