@@ -139,6 +139,8 @@ let nativeint_shiftop (l : constant list) (f : int32 -> int -> int32) : constant
139139 | [ NativeInt i; Int j ] -> Some (NativeInt (f i (Targetint. to_int_exn j)))
140140 | _ -> None
141141
142+ let quiet_nan n = Int64. logor n 0x00_08_00_00_00_00_00_00L
143+
142144let eval_prim ~target x =
143145 match x with
144146 | Not , [ Int i ] -> bool (Targetint. is_zero i)
@@ -236,7 +238,9 @@ let eval_prim ~target x =
236238 | `JavaScript ->
237239 let f = Int32. float_of_bits i in
238240 (not (Float. is_nan f))
239- || Int64. equal (Int64. bits_of_float f) (Int64. bits_of_float nan)
241+ || Int64. equal
242+ (quiet_nan (Int64. bits_of_float f))
243+ (Int64. bits_of_float nan)
240244 | `Wasm -> true -> Some (float (Int32. float_of_bits i))
241245 | "caml_int32_of_float" , [ Float f ] ->
242246 int32 (Int32. of_float (Int64. float_of_bits f))
@@ -269,7 +273,9 @@ let eval_prim ~target x =
269273 | `JavaScript ->
270274 let f = Int32. float_of_bits i in
271275 (not (Float. is_nan f))
272- || Int64. equal (Int64. bits_of_float f) (Int64. bits_of_float nan)
276+ || Int64. equal
277+ (quiet_nan (Int64. bits_of_float f))
278+ (Int64. bits_of_float nan)
273279 | `Wasm -> true -> Some (float (Int32. float_of_bits i))
274280 | "caml_nativeint_of_float" , [ Float f ] ->
275281 nativeint (Int32. of_float (Int64. float_of_bits f))
@@ -299,7 +305,7 @@ let eval_prim ~target x =
299305 when match target with
300306 | `JavaScript ->
301307 (not (Float. is_nan (Int64. float_of_bits i)))
302- || Int64. equal i (Int64. bits_of_float nan)
308+ || Int64. equal (quiet_nan i) (Int64. bits_of_float nan)
303309 | `Wasm -> true -> Some (Float i)
304310 | "caml_int64_of_float" , [ Float f ] ->
305311 int64 (Int64. of_float (Int64. float_of_bits f))
0 commit comments