-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
UInt64 to Double conversions are incorrect #43895
Comments
This looks to be a "known" issue and was done for "back compat": https://github.com/dotnet/runtime/blob/master/src/coreclr/src/jit/codegenxarch.cpp#L6435-L6468 Clang vs MSVC generate different code with the MSVC variant being similar to our own, but which produces a correct result: https://godbolt.org/z/P7j6n8 |
Given this is .NET Core and given this is a correctness issue; I would say we take the breaking change and ensure we generate the correct IEEE compliant conversion. |
I will investigate |
This is the backwartds compat comment in the JIT source code:
|
@briansull to discuss with @davidwrighton |
CC @dotnet/jit-contrib |
@davidwrighton recommends to fix this issue. |
Moved to .NET 7 as priority 1. For Vectors handling, consider a way to make it work without control flow. CC @dotnet/jit-contrib |
Moving to .NET 8. |
@tannergooding, assigning this to you for now. Please feel free to move out to Future. |
This got moved to early .NET 9 so we can handle all the "breaking changes" at once and early in the release |
Conversions from
UInt64
toDouble
for values greater thanlong.MaxValue
are currently incorrect. The same issue may exist forUInt32
toDouble
for values greater thanint.MaxValue
but I have not confirmed.The simple repro case is detailed here: dotnet/csharplang#4074
You can see approximately what the runtime generates by looking at: https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWzQBMQBqAHwAEAmARgFgAoSgZgAIa2BhNgbybaCO7IhACuwADYw2AWQAUYyRAB2AczYIAlHwFD9lAOyaA3HsEBfJhaA===
Which results in:
The constant used by
L0011
appears to be1.8446744073709552E+19
(0x43f0000000000000
)category:correctness
theme:optimization
skill-level:beginner
cost:small
impact:small
The text was updated successfully, but these errors were encountered: