@@ -2,7 +2,7 @@ use crate::simd::intrinsics::{
2
2
simd_reduce_add_ordered, simd_reduce_and, simd_reduce_max, simd_reduce_min,
3
3
simd_reduce_mul_ordered, simd_reduce_or, simd_reduce_xor,
4
4
} ;
5
- use crate :: simd:: { LaneCount , Simd , SupportedLaneCount } ;
5
+ use crate :: simd:: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
6
6
7
7
macro_rules! impl_integer_reductions {
8
8
{ $scalar: ty } => {
@@ -42,18 +42,6 @@ macro_rules! impl_integer_reductions {
42
42
pub fn horizontal_xor( self ) -> $scalar {
43
43
unsafe { simd_reduce_xor( self ) }
44
44
}
45
-
46
- /// Horizontal maximum. Returns the maximum lane in the vector.
47
- #[ inline]
48
- pub fn horizontal_max( self ) -> $scalar {
49
- unsafe { simd_reduce_max( self ) }
50
- }
51
-
52
- /// Horizontal minimum. Returns the minimum lane in the vector.
53
- #[ inline]
54
- pub fn horizontal_min( self ) -> $scalar {
55
- unsafe { simd_reduce_min( self ) }
56
- }
57
45
}
58
46
}
59
47
}
@@ -97,13 +85,22 @@ macro_rules! impl_float_reductions {
97
85
unsafe { simd_reduce_mul_ordered( self , 1. ) }
98
86
}
99
87
}
88
+ }
89
+ }
90
+ }
91
+
100
92
93
+ impl < T , const LANES : usize > Simd < T , LANES >
94
+ where
95
+ T : SimdElement + PartialOrd ,
96
+ LaneCount < LANES > : SupportedLaneCount ,
97
+ {
101
98
/// Horizontal maximum. Returns the maximum lane in the vector.
102
99
///
103
100
/// Returns values based on equality, so a vector containing both `0.` and `-0.` may
104
101
/// return either. This function will not return `NaN` unless all lanes are `NaN`.
105
102
#[ inline]
106
- pub fn horizontal_max( self ) -> $scalar {
103
+ pub fn horizontal_max ( self ) -> T {
107
104
unsafe { simd_reduce_max ( self ) }
108
105
}
109
106
@@ -112,11 +109,9 @@ macro_rules! impl_float_reductions {
112
109
/// Returns values based on equality, so a vector containing both `0.` and `-0.` may
113
110
/// return either. This function will not return `NaN` unless all lanes are `NaN`.
114
111
#[ inline]
115
- pub fn horizontal_min( self ) -> $scalar {
112
+ pub fn horizontal_min ( self ) -> T {
116
113
unsafe { simd_reduce_min ( self ) }
117
114
}
118
- }
119
- }
120
115
}
121
116
122
117
impl_float_reductions ! { f32 }
0 commit comments