-
Notifications
You must be signed in to change notification settings - Fork 293
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
f32/64.neg/abs may be wrong #70
Comments
It well might be! We didn't spent much time on float stuff and, I think, we even not passing testsuite for float. |
It seems that there is no separate instruction in LLVM that acts as |
Also, just in case you interested, in #72 I've enabled fp tests and they should pass now. |
While there is no separate instruction for it in LLVM, the reference manual specifically calls out that subtracting from 0 is not correct:
I don't know enough about floating point to be able to judge whether there's any actual difference, but is there anything stopping you from just implementing it as: f32::from_bits(val.to_bits() ^ 0x8000_0000) |
Yeah, that's because the IEEE 754 tells the same! Personally, I'd perfer using So before doing that change, I would like to be sure that this is actually a problem. I think running the testsuite on a some exotic (fp-wise) arch such as MIPS would be enough to discover problems if they are actually present! |
After all we ended up with raw bit manipulation, see #87 ! |
It seems like it delegates the implementations to Rust's f32/64::neg/abs which might to be wrong as according to https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#floating-point-negate
those instructions are supposed to be bitwise instructions that preserve the bits, so they can't be implemented as subtractions. However f32/64::neg generate the following LLVM IR:
The text was updated successfully, but these errors were encountered: