@@ -263,6 +263,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
263263 2 , // log2(4)
264264 ) ;
265265
266+ // Clamp the result to the guaranteed range of this function according to the C standard,
267+ // if any.
266268 match intrinsic_name {
267269 // sin and cos: [-1, 1]
268270 "sinf32" | "cosf32" => res. clamp ( Single :: one ( ) . neg ( ) , Single :: one ( ) ) ,
@@ -311,7 +313,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
311313 2 , // log2(4)
312314 ) ;
313315
314- // Clamp values to the output range defined in IEEE 754 9.1.
316+ // Clamp the result to the guaranteed range of this function according to the C standard,
317+ // if any.
315318 match intrinsic_name {
316319 // sin and cos: [-1, 1]
317320 "sinf64" | "cosf64" => res. clamp ( Double :: one ( ) . neg ( ) , Double :: one ( ) ) ,
@@ -383,8 +386,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
383386 let f2 = this. read_scalar ( f2) ?. to_f32 ( ) ?;
384387
385388 let fixed_res = match ( f1. category ( ) , f2. category ( ) ) {
386- // 1^y = 1 for any y even a NaN.
387- // TODO: C Standard says any NaN, IEEE says not a Signaling NaN
389+ // 1^y = 1 for any y, even a NaN.
388390 ( Category :: Normal , _) if f1 == 1.0f32 . to_soft ( ) => Some ( 1.0f32 . to_soft ( ) ) ,
389391
390392 // (-1)^(±INF) = 1
@@ -415,7 +417,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
415417
416418 let fixed_res = match ( f1. category ( ) , f2. category ( ) ) {
417419 // 1^y = 1 for any y even a NaN.
418- // TODO: C says any NaN, IEEE says no a Sign NaN
419420 ( Category :: Normal , _) if f1 == 1.0f64 . to_soft ( ) => Some ( 1.0f64 . to_soft ( ) ) ,
420421
421422 // (-1)^(±INF) = 1
@@ -649,11 +650,10 @@ fn fixed_float_value<S: Semantics>(
649650where
650651 IeeeFloat < S > : std:: cmp:: PartialEq ,
651652{
652- // TODO: Should we really fix to ±0? Applying an error has no effect.
653653 let one = IeeeFloat :: < S > :: one ( ) ;
654654 match intrinsic_name {
655- "sinf32" | "sinf64" if input . is_pos_zero ( ) => Some ( IeeeFloat :: < S > :: ZERO ) ,
656- "sinf32" | "sinf64" if input. is_neg_zero ( ) => Some ( - IeeeFloat :: < S > :: ZERO ) ,
655+ // sin(+- 0 ) = +- 0.
656+ "sinf32" | "sinf64" if input. is_zero ( ) => Some ( input ) ,
657657 "cosf32" | "cosf64" if input. is_zero ( ) => Some ( one) ,
658658 "expf32" | "expf64" | "exp2f32" | "exp2f64" if input. is_zero ( ) => Some ( one) ,
659659 #[ rustfmt:: skip]
0 commit comments