You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 2480 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Shawn Wagner
Version: 3.07
OS: Linux x86
Submission from: dialup-4.242.105.156.dial1.seattle1.level3.net (4.242.105.156)
ocamlopt doesn't seem to handle literal negative 0. values properly.
The following program:
let signbit x = Int64.shift_right_logical (Int64.bits_of_float x) 63 =
Int64.one
and zero = -0.0 in
Printf.printf "zero = %f and signbit zero = %b\n" zero (signbit zero)
will output 'zero = -0.000000 and signbit zero = true' when compiled with ocamlc
but 'zero = 0.000000 and signbit zero = false' when compiled with ocamlopt. The
negative sign's getting dropped somewhere.
peers at the source
It looks like the problem is in asmcomp/i386/emit.mlp in emit_instr in the
section that matches Lop(Iconst_float s). It compares the constant to 0.0 and
emits a fldz instruction. Since -0.0 and 0.0 are equal, it looses the signbit
there.
The text was updated successfully, but these errors were encountered:
Some more playing around produces this patch, which fixes the problem for
x86. I assume that all the native-code targets have the same issue, though.
*** asmcomp/i386/emit.mlp.orig Sun Apr 18 15:27:32 2004
--- asmcomp/i386/emit.mlp Sun Apr 18 16:05:11 2004
*** 400,408 **** movl ${emit_nativeint n}, {emit_reg i.res.(0)}\n
| Lop(Iconst_float s) ->
let f = float_of_string s in
! if f = 0.0 then
! fldz\n
! else if f = 1.0 then fld1\n
else begin
let lbl = new_label() in
--- 400,412 ---- movl ${emit_nativeint n}, {emit_reg i.res.(0)}\n
| Lop(Iconst_float s) ->
let f = float_of_string s in
! if f = 0.0 then begin
! if Int64.shift_right_logical (Int64.bits_of_float f) 63 = Int64.zero
! then (* +0.0 )
! fldz\n
! else ( -0.0 *)
! fldz\n fchs\n
! end else if f = 1.0 then fld1\n
else begin
let lbl = new_label() in
Original bug ID: 2480
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Shawn Wagner
Version: 3.07
OS: Linux x86
Submission from: dialup-4.242.105.156.dial1.seattle1.level3.net (4.242.105.156)
ocamlopt doesn't seem to handle literal negative 0. values properly.
The following program:
let signbit x = Int64.shift_right_logical (Int64.bits_of_float x) 63 =
Int64.one
and zero = -0.0 in
Printf.printf "zero = %f and signbit zero = %b\n" zero (signbit zero)
will output 'zero = -0.000000 and signbit zero = true' when compiled with ocamlc
but 'zero = 0.000000 and signbit zero = false' when compiled with ocamlopt. The
negative sign's getting dropped somewhere.
peers at the source
It looks like the problem is in asmcomp/i386/emit.mlp in emit_instr in the
section that matches Lop(Iconst_float s). It compares the constant to 0.0 and
emits a fldz instruction. Since -0.0 and 0.0 are equal, it looses the signbit
there.
The text was updated successfully, but these errors were encountered: