Skip to content

Commit 2288338

Browse files
Add support for xsimd::widen on WebAssembly
Related to #1179
1 parent f63bd07 commit 2288338

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/xsimd/arch/xsimd_wasm.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,24 @@ namespace xsimd
17011701
return wasm_f64x2_trunc(self);
17021702
}
17031703

1704+
// widen
1705+
template <class A>
1706+
XSIMD_INLINE std::array<batch<double, A>, 2> widen(batch<float, A> const& x, requires_arch<wasm>) noexcept
1707+
{
1708+
return { batch<double, A>(wasm_f64x2_promote_low_f32x4(x)),
1709+
batch<double, A>(wasm_f64x2_promote_low_f32x4(wasm_i32x4_shuffle(x, x, 2, 3, 0, 1))) };
1710+
}
1711+
template <class A>
1712+
XSIMD_INLINE std::array<batch<widen_t<uint8_t>, A>, 2> widen(batch<uint8_t, A> const& x, requires_arch<wasm>) noexcept
1713+
{
1714+
return { batch<widen_t<uint8_t>, A>(wasm_u16x8_extend_low_u8x16(x)), batch<widen_t<uint8_t>, A>(wasm_u16x8_extend_high_u8x16(x)) };
1715+
}
1716+
template <class A>
1717+
XSIMD_INLINE std::array<batch<widen_t<int8_t>, A>, 2> widen(batch<int8_t, A> const& x, requires_arch<wasm>) noexcept
1718+
{
1719+
return { batch<widen_t<int8_t>, A>(wasm_i16x8_extend_low_i8x16(x)), batch<widen_t<int8_t>, A>(wasm_i16x8_extend_high_i8x16(x)) };
1720+
}
1721+
17041722
// zip_hi
17051723
template <class A>
17061724
XSIMD_INLINE batch<float, A> zip_hi(batch<float, A> const& self, batch<float, A> const& other, requires_arch<wasm>) noexcept

0 commit comments

Comments
 (0)