Skip to content

Commit

Permalink
Added support for the neg operation
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Oct 11, 2023
1 parent 856e0c2 commit f489f63
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions include/xsimd/arch/xsimd_wasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,45 @@ namespace xsimd
return wasm_f64x2_mul(self, other);
}

// neg
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
inline batch<T, A> neg(batch<T, A> const& self, requires_arch<wasm>) noexcept
{
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
{
return wasm_i8x16_neg(self);
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
{
return wasm_i16x8_neg(self);
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
{
return wasm_i32x4_neg(self);
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
{
return wasm_i64x2_neg(self);
}
else
{
assert(false && "unsupported arch/op combination");
return {};
}
}

template <class A>
inline batch<float, A> neg(batch<float, A> const& self, requires_arch<wasm>) noexcept
{
return wasm_f32x4_neg(self);
}

template <class A>
inline batch<double, A> neg(batch<double, A> const& self, requires_arch<wasm>) noexcept
{
return wasm_f64x2_neg(self);
}

// neq
template <class A>
inline batch_bool<float, A> neq(batch<float, A> const& self, batch<float, A> const& other, requires_arch<wasm>) noexcept
Expand Down

0 comments on commit f489f63

Please sign in to comment.