@@ -747,7 +747,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
747
747
{
748
748
let a: F = self . read_scalar ( & args[ 0 ] ) ?. to_float ( ) ?;
749
749
let b: F = self . read_scalar ( & args[ 1 ] ) ?. to_float ( ) ?;
750
- let res = self . adjust_nan ( a. min ( b) , & [ a, b] ) ;
750
+ let res = if a == b {
751
+ // They are definitely not NaN (those are never equal), but they could be `+0` and `-0`.
752
+ // Let the machine decide which one to return.
753
+ M :: equal_float_min_max ( self , a, b)
754
+ } else {
755
+ self . adjust_nan ( a. min ( b) , & [ a, b] )
756
+ } ;
751
757
self . write_scalar ( res, dest) ?;
752
758
interp_ok ( ( ) )
753
759
}
@@ -762,7 +768,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
762
768
{
763
769
let a: F = self . read_scalar ( & args[ 0 ] ) ?. to_float ( ) ?;
764
770
let b: F = self . read_scalar ( & args[ 1 ] ) ?. to_float ( ) ?;
765
- let res = self . adjust_nan ( a. max ( b) , & [ a, b] ) ;
771
+ let res = if a == b {
772
+ // They are definitely not NaN (those are never equal), but they could be `+0` and `-0`.
773
+ // Let the machine decide which one to return.
774
+ M :: equal_float_min_max ( self , a, b)
775
+ } else {
776
+ self . adjust_nan ( a. max ( b) , & [ a, b] )
777
+ } ;
766
778
self . write_scalar ( res, dest) ?;
767
779
interp_ok ( ( ) )
768
780
}
0 commit comments