Skip to content

Commit 55b87f2

Browse files
committed
use rustc reductions
1 parent 38d41ab commit 55b87f2

File tree

14 files changed

+63
-1345
lines changed

14 files changed

+63
-1345
lines changed

coresimd/ppsv/api/arithmetic_reductions.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ macro_rules! impl_arithmetic_reductions {
77
/// Lane-wise addition of the vector elements.
88
#[inline]
99
pub fn sum(self) -> $elem_ty {
10-
super::codegen::sum::ReduceAdd::reduce_add(self)
10+
use ::coresimd::simd_llvm::simd_reduce_add_ordered;
11+
unsafe {
12+
simd_reduce_add_ordered(self, 0 as $elem_ty)
13+
}
1114
}
1215
/// Lane-wise multiplication of the vector elements.
1316
#[inline]
1417
pub fn product(self) -> $elem_ty {
15-
super::codegen::product::ReduceMul::reduce_mul(self)
18+
use ::coresimd::simd_llvm::simd_reduce_mul_ordered;
19+
unsafe {
20+
simd_reduce_add_ordered(self, 1 as $elem_ty)
21+
}
1622
}
1723
}
1824
}

coresimd/ppsv/api/bitwise_reductions.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,26 @@ macro_rules! impl_bitwise_reductions {
77
/// Lane-wise bitwise `and` of the vector elements.
88
#[inline]
99
pub fn and(self) -> $elem_ty {
10-
super::codegen::and::ReduceAnd::reduce_and(self)
10+
use ::coresimd::simd_llvm::simd_reduce_and;
11+
unsafe {
12+
simd_reduce_and(self)
13+
}
1114
}
1215
/// Lane-wise bitwise `or` of the vector elements.
1316
#[inline]
1417
pub fn or(self) -> $elem_ty {
15-
super::codegen::or::ReduceOr::reduce_or(self)
18+
use ::coresimd::simd_llvm::simd_reduce_or;
19+
unsafe {
20+
simd_reduce_or(self)
21+
}
1622
}
1723
/// Lane-wise bitwise `xor` of the vector elements.
1824
#[inline]
1925
pub fn xor(self) -> $elem_ty {
20-
super::codegen::xor::ReduceXor::reduce_xor(self)
26+
use ::coresimd::simd_llvm::simd_reduce_xor;
27+
unsafe {
28+
simd_reduce_xor(self)
29+
}
2130
}
2231
}
2332
}
@@ -29,17 +38,26 @@ macro_rules! impl_bool_bitwise_reductions {
2938
/// Lane-wise bitwise `and` of the vector elements.
3039
#[inline]
3140
pub fn and(self) -> $elem_ty {
32-
super::codegen::and::ReduceAnd::reduce_and(self) !=0
41+
use ::coresimd::simd_llvm::simd_reduce_and;
42+
unsafe {
43+
simd_reduce_and(self) != 0
44+
}
3345
}
3446
/// Lane-wise bitwise `or` of the vector elements.
3547
#[inline]
3648
pub fn or(self) -> $elem_ty {
37-
super::codegen::or::ReduceOr::reduce_or(self) != 0
49+
use ::coresimd::simd_llvm::simd_reduce_or;
50+
unsafe {
51+
simd_reduce_or(self) != 0
52+
}
3853
}
3954
/// Lane-wise bitwise `xor` of the vector elements.
4055
#[inline]
4156
pub fn xor(self) -> $elem_ty {
42-
super::codegen::xor::ReduceXor::reduce_xor(self) != 0
57+
use ::coresimd::simd_llvm::simd_reduce_xor;
58+
unsafe {
59+
simd_reduce_xor(self) != 0
60+
}
4361
}
4462
}
4563
}

coresimd/ppsv/api/boolean_reductions.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ macro_rules! impl_bool_reductions {
77
/// Are `all` vector lanes `true`?
88
#[inline]
99
pub fn all(self) -> bool {
10-
self.and()
10+
use ::coresimd::simd_llvm::simd_reduce_all;
11+
unsafe {
12+
simd_reduce_all(self)
13+
}
1114
}
1215
/// Is `any` vector lanes `true`?
1316
#[inline]
1417
pub fn any(self) -> bool {
15-
self.or()
18+
use ::coresimd::simd_llvm::simd_reduce_any;
19+
unsafe {
20+
simd_reduce_any(self)
21+
}
1622
}
1723
/// Are `all` vector lanes `false`?
1824
#[inline]
1925
pub fn none(self) -> bool {
20-
!self.or()
26+
!self.any()
2127
}
2228
}
2329
}

coresimd/ppsv/api/minmax_reductions.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ macro_rules! impl_minmax_reductions {
77
/// Largest vector value.
88
#[inline]
99
pub fn max(self) -> $elem_ty {
10-
super::codegen::max::ReduceMax::reduce_max(self)
10+
use ::coresimd::simd_llvm::simd_reduce_max;
11+
unsafe {
12+
simd_reduce_max(self)
13+
}
1114
}
1215
/// Smallest vector value.
1316
#[inline]
1417
pub fn min(self) -> $elem_ty {
15-
super::codegen::min::ReduceMin::reduce_min(self)
18+
use ::coresimd::simd_llvm::simd_reduce_min;
19+
unsafe {
20+
simd_reduce_min(self)
21+
}
1622
}
1723
}
1824
}

coresimd/ppsv/codegen/and.rs

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)