@@ -2,7 +2,7 @@ use crate::simd::intrinsics::{
22 simd_reduce_add_ordered, simd_reduce_and, simd_reduce_max, simd_reduce_min,
33 simd_reduce_mul_ordered, simd_reduce_or, simd_reduce_xor,
44} ;
5- use crate :: simd:: { LaneCount , Simd , SupportedLaneCount } ;
5+ use crate :: simd:: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
66
77macro_rules! impl_integer_reductions {
88 { $scalar: ty } => {
@@ -42,18 +42,6 @@ macro_rules! impl_integer_reductions {
4242 pub fn horizontal_xor( self ) -> $scalar {
4343 unsafe { simd_reduce_xor( self ) }
4444 }
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- }
5745 }
5846 }
5947}
@@ -97,25 +85,31 @@ macro_rules! impl_float_reductions {
9785 unsafe { simd_reduce_mul_ordered( self , 1. ) }
9886 }
9987 }
88+ }
89+ }
90+ }
10091
101- /// Horizontal maximum. Returns the maximum lane in the vector.
102- ///
103- /// Returns values based on equality, so a vector containing both `0.` and `-0.` may
104- /// return either. This function will not return `NaN` unless all lanes are `NaN`.
105- #[ inline]
106- pub fn horizontal_max( self ) -> $scalar {
107- unsafe { simd_reduce_max( self ) }
108- }
92+ impl < T , const LANES : usize > Simd < T , LANES >
93+ where
94+ T : SimdElement + PartialOrd ,
95+ LaneCount < LANES > : SupportedLaneCount ,
96+ {
97+ /// Horizontal maximum. Returns the maximum lane in the vector.
98+ ///
99+ /// Returns values based on equality, so a vector containing both `0.` and `-0.` may
100+ /// return either. This function will not return `NaN` unless all lanes are `NaN`.
101+ #[ inline]
102+ pub fn horizontal_max ( self ) -> T {
103+ unsafe { simd_reduce_max ( self ) }
104+ }
109105
110- /// Horizontal minimum. Returns the minimum lane in the vector.
111- ///
112- /// Returns values based on equality, so a vector containing both `0.` and `-0.` may
113- /// return either. This function will not return `NaN` unless all lanes are `NaN`.
114- #[ inline]
115- pub fn horizontal_min( self ) -> $scalar {
116- unsafe { simd_reduce_min( self ) }
117- }
118- }
106+ /// Horizontal minimum. Returns the minimum lane in the vector.
107+ ///
108+ /// Returns values based on equality, so a vector containing both `0.` and `-0.` may
109+ /// return either. This function will not return `NaN` unless all lanes are `NaN`.
110+ #[ inline]
111+ pub fn horizontal_min ( self ) -> T {
112+ unsafe { simd_reduce_min ( self ) }
119113 }
120114}
121115
0 commit comments