@@ -1408,23 +1408,42 @@ extern "rust-intrinsic" {
1408
1408
}
1409
1409
1410
1410
// Simple bootstrap implementations for stage0 compilation
1411
+
1411
1412
/// Returns the minimum of two `f32` values.
1412
1413
#[ cfg( stage0) ]
1413
1414
pub unsafe fn minnumf32 ( x : f32 , y : f32 ) -> f32 {
1415
+ // IEEE754 says: minNum(x, y) is the canonicalized number x if x < y, y if y < x, the
1416
+ // canonicalized number if one operand is a number and the other a quiet NaN. Otherwise it
1417
+ // is either x or y, canonicalized (this means results might differ among implementations).
1418
+ // When either x or y is a signalingNaN, then the result is according to 6.2.
1419
+ //
1420
+ // Since we do not support sNaN in Rust yet, we do not need to handle them.
1421
+ // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by
1422
+ // multiplying by 1.0. Should switch to the `canonicalize` when it works.
1414
1423
( if x < y || y != y { x } else { y } ) * 1.0
1415
1424
}
1416
1425
/// Returns the minimum of two `f64` values.
1417
1426
#[ cfg( stage0) ]
1418
1427
pub unsafe fn minnumf64 ( x : f64 , y : f64 ) -> f64 {
1428
+ // Identical to the `f32` case.
1419
1429
( if x < y || y != y { x } else { y } ) * 1.0
1420
1430
}
1421
1431
/// Returns the maximum of two `f32` values.
1422
1432
#[ cfg( stage0) ]
1423
1433
pub unsafe fn maxnumf32 ( x : f32 , y : f32 ) -> f32 {
1434
+ // IEEE754 says: maxNum(x, y) is the canonicalized number y if x < y, x if y < x, the
1435
+ // canonicalized number if one operand is a number and the other a quiet NaN. Otherwise it
1436
+ // is either x or y, canonicalized (this means results might differ among implementations).
1437
+ // When either x or y is a signalingNaN, then the result is according to 6.2.
1438
+ //
1439
+ // Since we do not support sNaN in Rust yet, we do not need to handle them.
1440
+ // FIXME(nagisa): due to https://bugs.llvm.org/show_bug.cgi?id=33303 we canonicalize by
1441
+ // multiplying by 1.0. Should switch to the `canonicalize` when it works.
1424
1442
( if x < y || x != x { y } else { x } ) * 1.0
1425
1443
}
1426
1444
/// Returns the maximum of two `f64` values.
1427
1445
#[ cfg( stage0) ]
1428
1446
pub unsafe fn maxnumf64 ( x : f64 , y : f64 ) -> f64 {
1447
+ // Identical to the `f32` case.
1429
1448
( if x < y || x != x { y } else { x } ) * 1.0
1430
1449
}
0 commit comments