Skip to content

Commit f83d894

Browse files
domibelserge-sans-paille
authored andcommitted
Add mul_hi kernels for lsx and lasx
1 parent 20c2789 commit f83d894

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

‎include/xsimd/arch/xsimd_lasx.hpp‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,34 @@ namespace xsimd
748748
return __lasx_xvfmul_d(self.data, other.data);
749749
}
750750

751+
// mul_hi
752+
template <class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
753+
XSIMD_INLINE batch<T, A> mul_hi(batch<T, A> const& self, batch<T, A> const& other, requires_arch<lasx>) noexcept
754+
{
755+
if constexpr (std::is_signed_v<T>)
756+
{
757+
if constexpr (sizeof(T) == 1)
758+
return __lasx_xvmuh_b(self.data, other.data);
759+
else if constexpr (sizeof(T) == 2)
760+
return __lasx_xvmuh_h(self.data, other.data);
761+
else if constexpr (sizeof(T) == 4)
762+
return __lasx_xvmuh_w(self.data, other.data);
763+
else
764+
return __lasx_xvmuh_d(self.data, other.data);
765+
}
766+
else
767+
{
768+
if constexpr (sizeof(T) == 1)
769+
return __lasx_xvmuh_bu(self.data, other.data);
770+
else if constexpr (sizeof(T) == 2)
771+
return __lasx_xvmuh_hu(self.data, other.data);
772+
else if constexpr (sizeof(T) == 4)
773+
return __lasx_xvmuh_wu(self.data, other.data);
774+
else
775+
return __lasx_xvmuh_du(self.data, other.data);
776+
}
777+
}
778+
751779
template <class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
752780
XSIMD_INLINE batch<T, A> neg(batch<T, A> const& self, requires_arch<lasx>) noexcept
753781
{

‎include/xsimd/arch/xsimd_lsx.hpp‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,34 @@ namespace xsimd
717717
return __lsx_vfmul_d(self.data, other.data);
718718
}
719719

720+
// mul_hi
721+
template <class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
722+
XSIMD_INLINE batch<T, A> mul_hi(batch<T, A> const& self, batch<T, A> const& other, requires_arch<lsx>) noexcept
723+
{
724+
if constexpr (std::is_signed_v<T>)
725+
{
726+
if constexpr (sizeof(T) == 1)
727+
return __lsx_vmuh_b(self.data, other.data);
728+
else if constexpr (sizeof(T) == 2)
729+
return __lsx_vmuh_h(self.data, other.data);
730+
else if constexpr (sizeof(T) == 4)
731+
return __lsx_vmuh_w(self.data, other.data);
732+
else
733+
return __lsx_vmuh_d(self.data, other.data);
734+
}
735+
else
736+
{
737+
if constexpr (sizeof(T) == 1)
738+
return __lsx_vmuh_bu(self.data, other.data);
739+
else if constexpr (sizeof(T) == 2)
740+
return __lsx_vmuh_hu(self.data, other.data);
741+
else if constexpr (sizeof(T) == 4)
742+
return __lsx_vmuh_wu(self.data, other.data);
743+
else
744+
return __lsx_vmuh_du(self.data, other.data);
745+
}
746+
}
747+
720748
template <class A, class T, class = std::enable_if_t<std::is_integral_v<T>>>
721749
XSIMD_INLINE batch<T, A> neg(batch<T, A> const& self, requires_arch<lsx>) noexcept
722750
{

0 commit comments

Comments
 (0)