@@ -552,6 +552,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
552552
553553/// Applies a random ULP floating point error to `val` and returns the new value.
554554/// So if you want an X ULP error, `ulp_exponent` should be log2(X).
555+ ///
555556/// Will fail if `val` is not a floating point number.
556557fn apply_random_float_error_to_imm < ' tcx > (
557558 ecx : & mut MiriInterpCx < ' tcx > ,
@@ -582,31 +583,19 @@ fn apply_random_float_error_to_imm<'tcx>(
582583/// - powf32, powf64
583584///
584585/// Returns Some(`output`) if the `intrinsic` results in a defined fixed `output` specified in the C standard when given `args`
585- /// as arguments, else None.
586+ /// as arguments. Outputs such as INF and zero are not considered. Otherwise this returns None.
586587fn fixed_float_value < S : Semantics > (
587588 intrinsic_name : & str ,
588589 args : & [ IeeeFloat < S > ] ,
589590) -> Option < IeeeFloat < S > > {
590591 let one = IeeeFloat :: < S > :: one ( ) ;
591592 match ( intrinsic_name, args) {
592- // sin(+- 0) = +- 0.
593- ( "sinf32" | "sinf64" , [ input] ) if input. is_zero ( ) => Some ( * input) ,
594-
595593 // cos(+- 0) = 1
596594 ( "cosf32" | "cosf64" , [ input] ) if input. is_zero ( ) => Some ( one) ,
597595
598596 // e^0 = 1
599597 ( "expf32" | "expf64" | "exp2f32" | "exp2f64" , [ input] ) if input. is_zero ( ) => Some ( one) ,
600598
601- // log(1) = 0
602- #[ rustfmt:: skip]
603- ( "logf32"
604- | "logf64"
605- | "log10f32"
606- | "log10f64"
607- | "log2f32"
608- | "log2f64" , [ input] ) if * input == one => Some ( IeeeFloat :: < S > :: ZERO ) ,
609-
610599 // 1^y = 1 for any y, even a NaN.
611600 ( "powf32" | "powf64" , [ base, _] ) if * base == one => Some ( one) ,
612601
@@ -616,8 +605,8 @@ fn fixed_float_value<S: Semantics>(
616605 // x^(±0) = 1 for any x, even a NaN
617606 ( "powf32" | "powf64" , [ _, exp] ) if exp. is_zero ( ) => Some ( one) ,
618607
619- // C standard doesn't specify any fixed outputs for other combinations of `intrinsic_name` and `args`,
620- // or an invalid combination was given .
608+ // There are a lot of cases for fixed outputs according to the C Standard, but these are mainly INF or zero
609+ // which are not affected by the applied error .
621610 _ => None ,
622611 }
623612}
0 commit comments