@@ -461,18 +461,16 @@ fn test_recip() {
461
461
#[ test]
462
462
#[ cfg( reliable_f16_math) ]
463
463
fn test_powi ( ) {
464
- // FIXME(llvm19): LLVM misoptimizes `powi.f16`
465
- // <https://github.com/llvm/llvm-project/issues/98665>
466
- // let nan: f16 = f16::NAN;
467
- // let inf: f16 = f16::INFINITY;
468
- // let neg_inf: f16 = f16::NEG_INFINITY;
469
- // assert_eq!(1.0f16.powi(1), 1.0);
470
- // assert_approx_eq!((-3.1f16).powi(2), 9.61, TOL_0);
471
- // assert_approx_eq!(5.9f16.powi(-2), 0.028727, TOL_N2);
472
- // assert_eq!(8.3f16.powi(0), 1.0);
473
- // assert!(nan.powi(2).is_nan());
474
- // assert_eq!(inf.powi(3), inf);
475
- // assert_eq!(neg_inf.powi(2), inf);
464
+ let nan: f16 = f16:: NAN ;
465
+ let inf: f16 = f16:: INFINITY ;
466
+ let neg_inf: f16 = f16:: NEG_INFINITY ;
467
+ assert_eq ! ( 1.0f16 . powi( 1 ) , 1.0 ) ;
468
+ assert_approx_eq ! ( ( -3.1f16 ) . powi( 2 ) , 9.61 , TOL_0 ) ;
469
+ assert_approx_eq ! ( 5.9f16 . powi( -2 ) , 0.028727 , TOL_N2 ) ;
470
+ assert_eq ! ( 8.3f16 . powi( 0 ) , 1.0 ) ;
471
+ assert ! ( nan. powi( 2 ) . is_nan( ) ) ;
472
+ assert_eq ! ( inf. powi( 3 ) , inf) ;
473
+ assert_eq ! ( neg_inf. powi( 2 ) , inf) ;
476
474
}
477
475
478
476
#[ test]
@@ -820,14 +818,13 @@ fn test_total_cmp() {
820
818
1 << ( f16:: MANTISSA_DIGITS - 2 )
821
819
}
822
820
823
- // FIXME(f16_f128): test subnormals when powf is available
824
- // fn min_subnorm() -> f16 {
825
- // f16::MIN_POSITIVE / f16::powf(2.0, f16::MANTISSA_DIGITS as f16 - 1.0)
826
- // }
821
+ fn min_subnorm ( ) -> f16 {
822
+ f16:: MIN_POSITIVE / f16:: powf ( 2.0 , f16:: MANTISSA_DIGITS as f16 - 1.0 )
823
+ }
827
824
828
- // fn max_subnorm() -> f16 {
829
- // f16::MIN_POSITIVE - min_subnorm()
830
- // }
825
+ fn max_subnorm ( ) -> f16 {
826
+ f16:: MIN_POSITIVE - min_subnorm ( )
827
+ }
831
828
832
829
fn q_nan ( ) -> f16 {
833
830
f16:: from_bits ( f16:: NAN . to_bits ( ) | quiet_bit_mask ( ) )
@@ -846,12 +843,12 @@ fn test_total_cmp() {
846
843
assert_eq ! ( Ordering :: Equal , ( -1.5_f16 ) . total_cmp( & -1.5 ) ) ;
847
844
assert_eq ! ( Ordering :: Equal , ( -0.5_f16 ) . total_cmp( & -0.5 ) ) ;
848
845
assert_eq ! ( Ordering :: Equal , ( -f16:: MIN_POSITIVE ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
849
- // assert_eq!(Ordering::Equal, (-max_subnorm()).total_cmp(&-max_subnorm()));
850
- // assert_eq!(Ordering::Equal, (-min_subnorm()).total_cmp(&-min_subnorm()));
846
+ assert_eq ! ( Ordering :: Equal , ( -max_subnorm( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
847
+ assert_eq ! ( Ordering :: Equal , ( -min_subnorm( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
851
848
assert_eq ! ( Ordering :: Equal , ( -0.0_f16 ) . total_cmp( & -0.0 ) ) ;
852
849
assert_eq ! ( Ordering :: Equal , 0.0_f16 . total_cmp( & 0.0 ) ) ;
853
- // assert_eq!(Ordering::Equal, min_subnorm().total_cmp(&min_subnorm()));
854
- // assert_eq!(Ordering::Equal, max_subnorm().total_cmp(&max_subnorm()));
850
+ assert_eq ! ( Ordering :: Equal , min_subnorm( ) . total_cmp( & min_subnorm( ) ) ) ;
851
+ assert_eq ! ( Ordering :: Equal , max_subnorm( ) . total_cmp( & max_subnorm( ) ) ) ;
855
852
assert_eq ! ( Ordering :: Equal , f16:: MIN_POSITIVE . total_cmp( & f16:: MIN_POSITIVE ) ) ;
856
853
assert_eq ! ( Ordering :: Equal , 0.5_f16 . total_cmp( & 0.5 ) ) ;
857
854
assert_eq ! ( Ordering :: Equal , 1.0_f16 . total_cmp( & 1.0 ) ) ;
@@ -870,13 +867,13 @@ fn test_total_cmp() {
870
867
assert_eq ! ( Ordering :: Less , ( -1.5_f16 ) . total_cmp( & -1.0 ) ) ;
871
868
assert_eq ! ( Ordering :: Less , ( -1.0_f16 ) . total_cmp( & -0.5 ) ) ;
872
869
assert_eq ! ( Ordering :: Less , ( -0.5_f16 ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
873
- // assert_eq!(Ordering::Less, (-f16::MIN_POSITIVE).total_cmp(&-max_subnorm()));
874
- // assert_eq!(Ordering::Less, (-max_subnorm()).total_cmp(&-min_subnorm()));
875
- // assert_eq!(Ordering::Less, (-min_subnorm()).total_cmp(&-0.0));
870
+ assert_eq ! ( Ordering :: Less , ( -f16:: MIN_POSITIVE ) . total_cmp( & -max_subnorm( ) ) ) ;
871
+ assert_eq ! ( Ordering :: Less , ( -max_subnorm( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
872
+ assert_eq ! ( Ordering :: Less , ( -min_subnorm( ) ) . total_cmp( & -0.0 ) ) ;
876
873
assert_eq ! ( Ordering :: Less , ( -0.0_f16 ) . total_cmp( & 0.0 ) ) ;
877
- // assert_eq!(Ordering::Less, 0.0_f16.total_cmp(&min_subnorm()));
878
- // assert_eq!(Ordering::Less, min_subnorm().total_cmp(&max_subnorm()));
879
- // assert_eq!(Ordering::Less, max_subnorm().total_cmp(&f16::MIN_POSITIVE));
874
+ assert_eq ! ( Ordering :: Less , 0.0_f16 . total_cmp( & min_subnorm( ) ) ) ;
875
+ assert_eq ! ( Ordering :: Less , min_subnorm( ) . total_cmp( & max_subnorm( ) ) ) ;
876
+ assert_eq ! ( Ordering :: Less , max_subnorm( ) . total_cmp( & f16:: MIN_POSITIVE ) ) ;
880
877
assert_eq ! ( Ordering :: Less , f16:: MIN_POSITIVE . total_cmp( & 0.5 ) ) ;
881
878
assert_eq ! ( Ordering :: Less , 0.5_f16 . total_cmp( & 1.0 ) ) ;
882
879
assert_eq ! ( Ordering :: Less , 1.0_f16 . total_cmp( & 1.5 ) ) ;
@@ -894,13 +891,13 @@ fn test_total_cmp() {
894
891
assert_eq ! ( Ordering :: Greater , ( -1.0_f16 ) . total_cmp( & -1.5 ) ) ;
895
892
assert_eq ! ( Ordering :: Greater , ( -0.5_f16 ) . total_cmp( & -1.0 ) ) ;
896
893
assert_eq ! ( Ordering :: Greater , ( -f16:: MIN_POSITIVE ) . total_cmp( & -0.5 ) ) ;
897
- // assert_eq!(Ordering::Greater, (-max_subnorm()).total_cmp(&-f16::MIN_POSITIVE));
898
- // assert_eq!(Ordering::Greater, (-min_subnorm()).total_cmp(&-max_subnorm()));
899
- // assert_eq!(Ordering::Greater, (-0.0_f16).total_cmp(&-min_subnorm()));
894
+ assert_eq ! ( Ordering :: Greater , ( -max_subnorm( ) ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
895
+ assert_eq ! ( Ordering :: Greater , ( -min_subnorm( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
896
+ assert_eq ! ( Ordering :: Greater , ( -0.0_f16 ) . total_cmp( & -min_subnorm( ) ) ) ;
900
897
assert_eq ! ( Ordering :: Greater , 0.0_f16 . total_cmp( & -0.0 ) ) ;
901
- // assert_eq!(Ordering::Greater, min_subnorm().total_cmp(&0.0));
902
- // assert_eq!(Ordering::Greater, max_subnorm().total_cmp(&min_subnorm()));
903
- // assert_eq!(Ordering::Greater, f16::MIN_POSITIVE.total_cmp(&max_subnorm()));
898
+ assert_eq ! ( Ordering :: Greater , min_subnorm( ) . total_cmp( & 0.0 ) ) ;
899
+ assert_eq ! ( Ordering :: Greater , max_subnorm( ) . total_cmp( & min_subnorm( ) ) ) ;
900
+ assert_eq ! ( Ordering :: Greater , f16:: MIN_POSITIVE . total_cmp( & max_subnorm( ) ) ) ;
904
901
assert_eq ! ( Ordering :: Greater , 0.5_f16 . total_cmp( & f16:: MIN_POSITIVE ) ) ;
905
902
assert_eq ! ( Ordering :: Greater , 1.0_f16 . total_cmp( & 0.5 ) ) ;
906
903
assert_eq ! ( Ordering :: Greater , 1.5_f16 . total_cmp( & 1.0 ) ) ;
@@ -918,12 +915,12 @@ fn test_total_cmp() {
918
915
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -1.0 ) ) ;
919
916
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -0.5 ) ) ;
920
917
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
921
- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-max_subnorm()));
922
- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-min_subnorm()));
918
+ assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
919
+ assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
923
920
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -0.0 ) ) ;
924
921
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 0.0 ) ) ;
925
- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&min_subnorm()));
926
- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&max_subnorm()));
922
+ assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & min_subnorm( ) ) ) ;
923
+ assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & max_subnorm( ) ) ) ;
927
924
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & f16:: MIN_POSITIVE ) ) ;
928
925
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 0.5 ) ) ;
929
926
assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 1.0 ) ) ;
@@ -940,12 +937,12 @@ fn test_total_cmp() {
940
937
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & -1.0 ) ) ;
941
938
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & -0.5 ) ) ;
942
939
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
943
- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-max_subnorm()));
944
- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-min_subnorm()));
940
+ assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
941
+ assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
945
942
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & -0.0 ) ) ;
946
943
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & 0.0 ) ) ;
947
- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&min_subnorm()));
948
- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&max_subnorm()));
944
+ assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & min_subnorm( ) ) ) ;
945
+ assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & max_subnorm( ) ) ) ;
949
946
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & f16:: MIN_POSITIVE ) ) ;
950
947
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & 0.5 ) ) ;
951
948
assert_eq ! ( Ordering :: Less , ( -s_nan( ) ) . total_cmp( & 1.0 ) ) ;
0 commit comments