@@ -851,9 +851,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
851851 let res = res. to_soft ( ) ;
852852 // Apply a relative error of 4ULP to introduce some non-determinism
853853 // 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 ) ;
857855
858856 // Clamp the result to the guaranteed range of this function according to the C standard,
859857 // if any.
@@ -872,27 +870,26 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
872870 let f1 = this. read_scalar ( f1) ?. to_f32 ( ) ?;
873871 let f2 = this. read_scalar ( f2) ?. to_f32 ( ) ?;
874872
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+ } ) ;
896893 let res = this. adjust_nan ( res, & [ f1, f2] ) ;
897894 this. write_scalar ( res, dest) ?;
898895 }
@@ -937,9 +934,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
937934 let res = res. to_soft ( ) ;
938935 // Apply a relative error of 4ULP to introduce some non-determinism
939936 // 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 ) ;
943938
944939 // Clamp the result to the guaranteed range of this function according to the C standard,
945940 // if any.
@@ -971,9 +966,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
971966 } ;
972967 // Apply a relative error of 4ULP to introduce some non-determinism
973968 // 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 ) ;
977970
978971 // Clamp the result to the guaranteed range of this function according to the C standard,
979972 // if any.
@@ -1008,7 +1001,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
10081001 let res = res. to_soft ( ) ;
10091002 // Apply a relative error of 4ULP to introduce some non-determinism
10101003 // 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 ) ;
10121005 // Clamp the result to the guaranteed range of this function according to the C standard,
10131006 // if any.
10141007 let res = math:: clamp_float_value ( link_name. as_str ( ) , res) ;
@@ -1027,7 +1020,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
10271020 let res = res. to_soft ( ) ;
10281021 // Apply a relative error of 4ULP to introduce some non-determinism
10291022 // 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 ) ;
10311024 // Clamp the result to the guaranteed range of this function according to the C standard,
10321025 // if any.
10331026 let res = math:: clamp_float_value ( link_name. as_str ( ) , res) ;
0 commit comments