-
Notifications
You must be signed in to change notification settings - Fork 2.6k
disable gtFoldExprConst for conversion from negative double to unsigned long #6754
Conversation
@dotnet/jit-contrib Would it be better to unconditionally disable gtFoldExprConst in the JIT where it gives undefined or imprecise results instead? We are going to be chasing mismatches between JIT and JIT helper implementations forever otherwise. |
@jkotas' valid question aside, I don't think I would change the behavior of a method called "FastDbl2Lng" so fundamentally without at least changing its name. Alternatively, I haven't gone through all the cases to be certain, but it feels like you ought to be modifying the JIT_Dbl2U* helpers directly and adding #ifdefs to detect the quirkiness of MSVC (#ifdef _MSC_VER?) versus other compilers, which may already not require the range-checking gymnastics currently implemented in the helpers. |
I fundamentally agree with @RussKeldorph 's opinion modifying JIT_Dbl2U* helpers directly. But I modified FastDbl2Lng because there was no helper functions in |
…RM (modify helper)
@dotnet-bot test Ubuntu x64 Checked Build and Test please |
@dotnet-bot test OSX x64 Checked Build and Test please |
@dotnet-bot test Windows_NT x64 Release Priority 1 Build and Test please |
Modify helper function @jkotas , @RussKeldorph could you please have a look? |
src/vm/jithelpers.cpp
Outdated
|
||
const double two63 = 2147483648.0 * 4294967296.0; | ||
UINT64 ret; | ||
#ifdef _TARGET_XARCH_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation works fine on Windows everywhere. We should keep using instead of the slower one below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkotas Could you recommend proper flag? We need to keep using upper one on Windows everywhere, and Linux for x86/x64.
I am still wondering that a better fix would be to remove this Line 12045 in df50db7
|
(@jkotas I was very confused for a bit since the line you referenced has moved recently. I edited your comment with the stable link, which you can get by pressing 'y' while viewing the unstable link in the browser.) @hseok-oh FWIW, I agree with @jkotas about gtFoldExprConst. I'm skeptical there is a code quality advantage to folding these cases which are problematic to emulate because the behavior is unspecified in both C++ and IL. |
@jkotas, @RussKeldorph I also agree with you about |
@dotnet-bot test Ubuntu x64 Checked Build and Test please |
@jkotas , @RussKeldorph I have modified |
Conflicts: src/jit/gentree.cpp
src/jit/gentree.cpp
Outdated
#endif //!_TARGET_XARCH_ | ||
} | ||
|
||
if (d1 < 0.0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be if (d1 <= 1.0)? I believe this is consistent with other places that test the same thing.
Also please place opening brace on next line. (Source formatting tool is close...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RussKeldorph Is it typo of if (d1 <= -1.0)
?
@jkotas , @RussKeldorph I've modified gtFoldExprConst by using |
@jkotas , @RussKeldorph PTAL |
LGTM |
@jkotas @RussKeldorph @JosephTremoulet ready to get merged. |
LGTM, but probably worth adding a comment indicating that we don't fold these cases because the result is unspecified per ECMA and the native math doing the fold doesn't match the run-time computation on all platforms and we want the behavior to be the same with or without folding. |
LGTM |
disable gtFoldExprConst for conversion from negative double to unsigned long Commit migrated from dotnet/coreclr@2448e08
Related issue: #6667
In ARM architecture, negative double is converted to zero when target is unsigned integer.
Reference comment and implementation:
FloatingPointUtils::convertDoubleToUInt64(double d)
in jit/utils.cpp