Skip to content

Commit c544507

Browse files
WIP
1 parent 5e5a19a commit c544507

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

include/xsimd/arch/xsimd_rvv.hpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,15 +1509,25 @@ namespace xsimd
15091509
}
15101510

15111511
// mask
1512-
template <class A, class T, class = std::enable_if_t<sizeof(T) >= batch_bool<T, A>::size>>
1512+
template <class A, class T>
1513+
XSIMD_INLINE uint64_t mask(batch_bool<T, A> const& self, requires_arch<common>) noexcept;
1514+
1515+
template <class A, class T>
15131516
XSIMD_INLINE uint64_t mask(batch_bool<T, A> const& self, requires_arch<rvv>) noexcept
15141517
{
1515-
const auto zero = detail::broadcast<as_unsigned_integer_t<T>, types::detail::rvv_width_m1>(T(0));
1516-
auto ones = detail::broadcast<as_unsigned_integer_t<T>, A::width>(1);
1517-
auto iota = detail::vindex<A, as_unsigned_integer_t<T>>();
1518-
auto upowers = detail::rvvsll(ones, iota);
1519-
auto r = __riscv_vredor(self.data.as_mask(), upowers, (typename decltype(zero)::register_type)zero, batch_bool<T, A>::size);
1520-
return detail::reduce_scalar<A, as_unsigned_integer_t<T>>(r);
1518+
XSIMD_IF_CONSTEXPR(sizeof(T) >= batch_bool<T, A>::size)
1519+
{
1520+
const auto zero = detail::broadcast<as_unsigned_integer_t<T>, types::detail::rvv_width_m1>(T(0));
1521+
auto ones = detail::broadcast<as_unsigned_integer_t<T>, A::width>(1);
1522+
auto iota = detail::vindex<A, as_unsigned_integer_t<T>>();
1523+
auto upowers = detail::rvvsll(ones, iota);
1524+
auto r = __riscv_vredor(self.data.as_mask(), upowers, (typename decltype(zero)::register_type)zero, batch_bool<T, A>::size);
1525+
return detail::reduce_scalar<A, as_unsigned_integer_t<T>>(r);
1526+
}
1527+
else
1528+
{
1529+
return mask(self, common {});
1530+
}
15211531
}
15221532
} // namespace kernel
15231533
} // namespace xsimd

0 commit comments

Comments
 (0)