@@ -6,7 +6,7 @@ macro_rules! impl_unary_op_test {
66 { $scalar: ty, $trait: ident :: $fn: ident, $scalar_fn: expr } => {
77 test_helpers:: test_lanes! {
88 fn $fn<const LANES : usize >( ) {
9- test_helpers:: test_unary_elementwise (
9+ test_helpers:: test_unary_elementwise_flush_subnormals (
1010 & <core_simd:: simd:: Simd <$scalar, LANES > as core:: ops:: $trait>:: $fn,
1111 & $scalar_fn,
1212 & |_| true ,
@@ -31,15 +31,15 @@ macro_rules! impl_binary_op_test {
3131
3232 test_helpers:: test_lanes! {
3333 fn normal<const LANES : usize >( ) {
34- test_helpers:: test_binary_elementwise (
34+ test_helpers:: test_binary_elementwise_flush_subnormals (
3535 & <Simd <$scalar, LANES > as core:: ops:: $trait>:: $fn,
3636 & $scalar_fn,
3737 & |_, _| true ,
3838 ) ;
3939 }
4040
4141 fn assign<const LANES : usize >( ) {
42- test_helpers:: test_binary_elementwise (
42+ test_helpers:: test_binary_elementwise_flush_subnormals (
4343 & |mut a, b| { <Simd <$scalar, LANES > as core:: ops:: $trait_assign>:: $fn_assign( & mut a, b) ; a } ,
4444 & $scalar_fn,
4545 & |_, _| true ,
@@ -126,19 +126,23 @@ macro_rules! impl_common_integer_tests {
126126
127127 fn reduce_sum<const LANES : usize >( ) {
128128 test_helpers:: test_1( & |x| {
129+ use test_helpers:: subnormals:: { flush, flush_in} ;
129130 test_helpers:: prop_assert_biteq! (
130131 $vector:: <LANES >:: from_array( x) . reduce_sum( ) ,
131132 x. iter( ) . copied( ) . fold( 0 as $scalar, $scalar:: wrapping_add) ,
133+ flush( x. iter( ) . copied( ) . map( flush_in) . fold( 0 as $scalar, $scalar:: wrapping_add) ) ,
132134 ) ;
133135 Ok ( ( ) )
134136 } ) ;
135137 }
136138
137139 fn reduce_product<const LANES : usize >( ) {
138140 test_helpers:: test_1( & |x| {
141+ use test_helpers:: subnormals:: { flush, flush_in} ;
139142 test_helpers:: prop_assert_biteq! (
140143 $vector:: <LANES >:: from_array( x) . reduce_product( ) ,
141144 x. iter( ) . copied( ) . fold( 1 as $scalar, $scalar:: wrapping_mul) ,
145+ flush( x. iter( ) . copied( ) . map( flush_in) . fold( 1 as $scalar, $scalar:: wrapping_mul) ) ,
142146 ) ;
143147 Ok ( ( ) )
144148 } ) ;
@@ -463,15 +467,15 @@ macro_rules! impl_float_tests {
463467 }
464468
465469 fn to_degrees<const LANES : usize >( ) {
466- test_helpers:: test_unary_elementwise (
470+ test_helpers:: test_unary_elementwise_flush_subnormals (
467471 & Vector :: <LANES >:: to_degrees,
468472 & Scalar :: to_degrees,
469473 & |_| true ,
470474 )
471475 }
472476
473477 fn to_radians<const LANES : usize >( ) {
474- test_helpers:: test_unary_elementwise (
478+ test_helpers:: test_unary_elementwise_flush_subnormals (
475479 & Vector :: <LANES >:: to_radians,
476480 & Scalar :: to_radians,
477481 & |_| true ,
@@ -541,7 +545,12 @@ macro_rules! impl_float_tests {
541545 }
542546
543547 fn simd_clamp<const LANES : usize >( ) {
548+ if cfg!( all( target_arch = "powerpc64" , target_feature = "vsx" ) ) {
549+ // https://gitlab.com/qemu-project/qemu/-/issues/1780
550+ return ;
551+ }
544552 test_helpers:: test_3( & |value: [ Scalar ; LANES ] , mut min: [ Scalar ; LANES ] , mut max: [ Scalar ; LANES ] | {
553+ use test_helpers:: subnormals:: flush_in;
545554 for ( min, max) in min. iter_mut( ) . zip( max. iter_mut( ) ) {
546555 if max < min {
547556 core:: mem:: swap( min, max) ;
@@ -558,8 +567,20 @@ macro_rules! impl_float_tests {
558567 for i in 0 ..LANES {
559568 result_scalar[ i] = value[ i] . clamp( min[ i] , max[ i] ) ;
560569 }
570+ let mut result_scalar_flush = [ Scalar :: default ( ) ; LANES ] ;
571+ for i in 0 ..LANES {
572+ // Comparisons flush-to-zero, but return value selection is _not_ flushed.
573+ let mut value = value[ i] ;
574+ if flush_in( value) < flush_in( min[ i] ) {
575+ value = min[ i] ;
576+ }
577+ if flush_in( value) > flush_in( max[ i] ) {
578+ value = max[ i] ;
579+ }
580+ result_scalar_flush[ i] = value
581+ }
561582 let result_vector = Vector :: from_array( value) . simd_clamp( min. into( ) , max. into( ) ) . to_array( ) ;
562- test_helpers:: prop_assert_biteq!( result_scalar, result_vector ) ;
583+ test_helpers:: prop_assert_biteq!( result_vector , result_scalar, result_scalar_flush ) ;
563584 Ok ( ( ) )
564585 } )
565586 }
0 commit comments