@@ -263,6 +263,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
263
263
2 , // log2(4)
264
264
) ;
265
265
266
+ // Clamp the result to the guaranteed range of this function according to the C standard,
267
+ // if any.
266
268
match intrinsic_name {
267
269
// sin and cos: [-1, 1]
268
270
"sinf32" | "cosf32" => res. clamp ( Single :: one ( ) . neg ( ) , Single :: one ( ) ) ,
@@ -311,7 +313,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
311
313
2 , // log2(4)
312
314
) ;
313
315
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.
315
318
match intrinsic_name {
316
319
// sin and cos: [-1, 1]
317
320
"sinf64" | "cosf64" => res. clamp ( Double :: one ( ) . neg ( ) , Double :: one ( ) ) ,
@@ -383,8 +386,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
383
386
let f2 = this. read_scalar ( f2) ?. to_f32 ( ) ?;
384
387
385
388
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.
388
390
( Category :: Normal , _) if f1 == 1.0f32 . to_soft ( ) => Some ( 1.0f32 . to_soft ( ) ) ,
389
391
390
392
// (-1)^(±INF) = 1
@@ -415,7 +417,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
415
417
416
418
let fixed_res = match ( f1. category ( ) , f2. category ( ) ) {
417
419
// 1^y = 1 for any y even a NaN.
418
- // TODO: C says any NaN, IEEE says no a Sign NaN
419
420
( Category :: Normal , _) if f1 == 1.0f64 . to_soft ( ) => Some ( 1.0f64 . to_soft ( ) ) ,
420
421
421
422
// (-1)^(±INF) = 1
@@ -649,11 +650,10 @@ fn fixed_float_value<S: Semantics>(
649
650
where
650
651
IeeeFloat < S > : std:: cmp:: PartialEq ,
651
652
{
652
- // TODO: Should we really fix to ±0? Applying an error has no effect.
653
653
let one = IeeeFloat :: < S > :: one ( ) ;
654
654
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 ) ,
657
657
"cosf32" | "cosf64" if input. is_zero ( ) => Some ( one) ,
658
658
"expf32" | "expf64" | "exp2f32" | "exp2f64" if input. is_zero ( ) => Some ( one) ,
659
659
#[ rustfmt:: skip]
0 commit comments