-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[interpreter] fp tests fail on Windows 32 due to bit pattern mismatches #124
Comments
The test at float_misc.wast:92 is the first of a series of tests with the comment "Computations that round differently on x87", so it's likely that the bug here is OCaml using x87 arithmetic on Windows. The problem with x87 math in this case is double rounding, with results being first rounded to 80-bit precision and then rounded from there to 64-bit precision. This gives different results in some cases than if the value had been rounded to 64-bit precision directly. Possible workaroundsIs this a debug or opt build? If an opt build, does anyone know if there's a way to force ocaml to use sse math instead of x87 math? Alternatively, is this a 32-bit or 64-bit build? If 32-bit, are you able to try 64-bit? 64-bit is more likely to default to sse math. If a debug build, if I read the OCaml source correctly, fp math is implemented in C code, so would it be possible to recompile your OCaml installation with sse enabled? I see mentions of mingw in the documentation; if so, the requisite command-line flags may be -msse2 -mfp-math=sse. Alternatively, a 64-bit may be more likely to default to sse math. Possible fixesIt's also theoretically possible to write the spec interpreter to work around this problem. While there are techniques for achieving the desired rounding behavior in terms of x87 operations, I think someone at some point mentioned that there are software floating point implementations available for OCaml, and for the spec repo that might be best, keeping things simple. All floating point logic in the spec is factored out into spec/f32.ml, spec/f64.ml, and spec/*_convert.ml, so it should be fairly straightforward to port. |
I see this issue on 32-bit Linux as well, but not on 64-bit. So it definitely looks like an issue with 32-bit ocaml. Btw, I also saw the problem on 32-bit gcc as well, on the binaryen interpreter. @sunfishcode showed me that can be avoided by telling gcc to not use x87, with the flags |
Is this still an issue or can it be closed now? |
Still an issue for those who care about compiling on x86-32. |
Closing as "won't fix". |
nmadd(x, y, z) == nmadd(-x, y, z) the tests were doing -z instead.
The text was updated successfully, but these errors were encountered: