Remove wrapping from sum/product fns

This commit is contained in:
Caleb Zulawski 2021-04-22 22:41:12 +00:00
parent 828b274ae7
commit 04ee107323
2 changed files with 6 additions and 6 deletions

View file

@ -6,13 +6,13 @@ macro_rules! impl_integer_reductions {
{
/// Horizontal wrapping add. Returns the sum of the lanes of the vector, with wrapping addition.
#[inline]
pub fn horizontal_wrapping_sum(self) -> $scalar {
pub fn horizontal_sum(self) -> $scalar {
unsafe { crate::intrinsics::simd_reduce_add_ordered(self, 0) }
}
/// Horizontal wrapping multiply. Returns the product of the lanes of the vector, with wrapping multiplication.
#[inline]
pub fn horizontal_wrapping_product(self) -> $scalar {
pub fn horizontal_product(self) -> $scalar {
unsafe { crate::intrinsics::simd_reduce_mul_ordered(self, 1) }
}

View file

@ -140,20 +140,20 @@ macro_rules! impl_binary_checked_op_test {
macro_rules! impl_common_integer_tests {
{ $vector:ident, $scalar:ident } => {
test_helpers::test_lanes! {
fn horizontal_wrapping_sum<const LANES: usize>() {
fn horizontal_sum<const LANES: usize>() {
test_helpers::test_1(&|x| {
test_helpers::prop_assert_biteq! (
$vector::<LANES>::from_array(x).horizontal_wrapping_sum(),
$vector::<LANES>::from_array(x).horizontal_sum(),
x.iter().copied().fold(0 as $scalar, $scalar::wrapping_add),
);
Ok(())
});
}
fn horizontal_wrapping_product<const LANES: usize>() {
fn horizontal_product<const LANES: usize>() {
test_helpers::test_1(&|x| {
test_helpers::prop_assert_biteq! (
$vector::<LANES>::from_array(x).horizontal_wrapping_product(),
$vector::<LANES>::from_array(x).horizontal_product(),
x.iter().copied().fold(1 as $scalar, $scalar::wrapping_mul),
);
Ok(())