@@ -851,9 +851,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
851
851
let res = res. to_soft ( ) ;
852
852
// Apply a relative error of 4ULP to introduce some non-determinism
853
853
// simulating imprecise implementations and optimizations.
854
- let res = math:: apply_random_float_error_ulp (
855
- this, res, 2 , // log2(4)
856
- ) ;
854
+ let res = math:: apply_random_float_error_ulp ( this, res, 4 ) ;
857
855
858
856
// Clamp the result to the guaranteed range of this function according to the C standard,
859
857
// if any.
@@ -872,27 +870,26 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
872
870
let f1 = this. read_scalar ( f1) ?. to_f32 ( ) ?;
873
871
let f2 = this. read_scalar ( f2) ?. to_f32 ( ) ?;
874
872
875
- let res = math:: fixed_float_value ( this, link_name. as_str ( ) , & [ f1, f2] ) . unwrap_or_else ( || {
876
- let res = match link_name. as_str ( ) {
877
- // underscore case for windows, here and below
878
- // (see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/floating-point-primitives?view=vs-2019)
879
- // Using host floats (but it's fine, these operations do not have guaranteed precision).
880
- "_hypotf" | "hypotf" => f1. to_host ( ) . hypot ( f2. to_host ( ) ) . to_soft ( ) ,
881
- "atan2f" => f1. to_host ( ) . atan2 ( f2. to_host ( ) ) . to_soft ( ) ,
882
- #[ allow( deprecated) ]
883
- "fdimf" => f1. to_host ( ) . abs_sub ( f2. to_host ( ) ) . to_soft ( ) ,
884
- _ => bug ! ( ) ,
885
- } ;
886
- // Apply a relative error of 4ULP to introduce some non-determinism
887
- // simulating imprecise implementations and optimizations.
888
- let res = math:: apply_random_float_error_ulp (
889
- this, res, 2 , // log2(4)
890
- ) ;
891
-
892
- // Clamp the result to the guaranteed range of this function according to the C standard,
893
- // if any.
894
- math:: clamp_float_value ( link_name. as_str ( ) , res)
895
- } ) ;
873
+ let res = math:: fixed_float_value ( this, link_name. as_str ( ) , & [ f1, f2] )
874
+ . unwrap_or_else ( || {
875
+ let res = match link_name. as_str ( ) {
876
+ // underscore case for windows, here and below
877
+ // (see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/floating-point-primitives?view=vs-2019)
878
+ // Using host floats (but it's fine, these operations do not have guaranteed precision).
879
+ "_hypotf" | "hypotf" => f1. to_host ( ) . hypot ( f2. to_host ( ) ) . to_soft ( ) ,
880
+ "atan2f" => f1. to_host ( ) . atan2 ( f2. to_host ( ) ) . to_soft ( ) ,
881
+ #[ allow( deprecated) ]
882
+ "fdimf" => f1. to_host ( ) . abs_sub ( f2. to_host ( ) ) . to_soft ( ) ,
883
+ _ => bug ! ( ) ,
884
+ } ;
885
+ // Apply a relative error of 4ULP to introduce some non-determinism
886
+ // simulating imprecise implementations and optimizations.
887
+ let res = math:: apply_random_float_error_ulp ( this, res, 4 ) ;
888
+
889
+ // Clamp the result to the guaranteed range of this function according to the C standard,
890
+ // if any.
891
+ math:: clamp_float_value ( link_name. as_str ( ) , res)
892
+ } ) ;
896
893
let res = this. adjust_nan ( res, & [ f1, f2] ) ;
897
894
this. write_scalar ( res, dest) ?;
898
895
}
@@ -937,9 +934,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
937
934
let res = res. to_soft ( ) ;
938
935
// Apply a relative error of 4ULP to introduce some non-determinism
939
936
// simulating imprecise implementations and optimizations.
940
- let res = math:: apply_random_float_error_ulp (
941
- this, res, 2 , // log2(4)
942
- ) ;
937
+ let res = math:: apply_random_float_error_ulp ( this, res, 4 ) ;
943
938
944
939
// Clamp the result to the guaranteed range of this function according to the C standard,
945
940
// if any.
@@ -971,9 +966,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
971
966
} ;
972
967
// Apply a relative error of 4ULP to introduce some non-determinism
973
968
// simulating imprecise implementations and optimizations.
974
- let res = math:: apply_random_float_error_ulp (
975
- this, res, 2 , // log2(4)
976
- ) ;
969
+ let res = math:: apply_random_float_error_ulp ( this, res, 4 ) ;
977
970
978
971
// Clamp the result to the guaranteed range of this function according to the C standard,
979
972
// if any.
@@ -1008,7 +1001,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
1008
1001
let res = res. to_soft ( ) ;
1009
1002
// Apply a relative error of 4ULP to introduce some non-determinism
1010
1003
// simulating imprecise implementations and optimizations.
1011
- let res = math:: apply_random_float_error_ulp ( this, res, 2 /* log2(4) */ ) ;
1004
+ let res = math:: apply_random_float_error_ulp ( this, res, 4 ) ;
1012
1005
// Clamp the result to the guaranteed range of this function according to the C standard,
1013
1006
// if any.
1014
1007
let res = math:: clamp_float_value ( link_name. as_str ( ) , res) ;
@@ -1027,7 +1020,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
1027
1020
let res = res. to_soft ( ) ;
1028
1021
// Apply a relative error of 4ULP to introduce some non-determinism
1029
1022
// simulating imprecise implementations and optimizations.
1030
- let res = math:: apply_random_float_error_ulp ( this, res, 2 /* log2(4) */ ) ;
1023
+ let res = math:: apply_random_float_error_ulp ( this, res, 4 ) ;
1031
1024
// Clamp the result to the guaranteed range of this function according to the C standard,
1032
1025
// if any.
1033
1026
let res = math:: clamp_float_value ( link_name. as_str ( ) , res) ;
0 commit comments