@@ -747,7 +747,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
747747 {
748748 let a: F = self . read_scalar ( & args[ 0 ] ) ?. to_float ( ) ?;
749749 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+ } ;
751757 self . write_scalar ( res, dest) ?;
752758 interp_ok ( ( ) )
753759 }
@@ -762,7 +768,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
762768 {
763769 let a: F = self . read_scalar ( & args[ 0 ] ) ?. to_float ( ) ?;
764770 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+ } ;
766778 self . write_scalar ( res, dest) ?;
767779 interp_ok ( ( ) )
768780 }
0 commit comments