From ae336e6da4bd61da4e3f11e9f7d2284b766f701c Mon Sep 17 00:00:00 2001 From: Hyeongseok Oh Date: Fri, 19 Aug 2016 11:06:52 +0900 Subject: [PATCH] fix for correct conversion from negative double to unsigned long in ARM (modify helper) Commit migrated from https://github.com/dotnet/coreclr/commit/39302ecfa7a32bb39d30e299a1863d0af59c31c5 --- src/coreclr/src/vm/jithelpers.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/coreclr/src/vm/jithelpers.cpp b/src/coreclr/src/vm/jithelpers.cpp index 1f7c630..0f05342 100644 --- a/src/coreclr/src/vm/jithelpers.cpp +++ b/src/coreclr/src/vm/jithelpers.cpp @@ -588,17 +588,8 @@ FORCEINLINE INT64 FastDbl2Lng(double val) FCALL_CONTRACT; return HCCALL1_V(JIT_Dbl2Lng, val); #else -// In x86/x64, conversion result of negative double to unsigned integer is -// bit-equivalent unsigned value. -// But other architecture's compiler convert negative doubles to zero when -// the target is unsigned. -#ifdef _TARGET_XARCH_ FCALL_CONTRACT; return((__int64) val); -#else - FCALL_CONTRACT; - return((unsigned __int64) val); -#endif #endif } @@ -623,7 +614,15 @@ HCIMPL1_V(UINT64, JIT_Dbl2ULng, double val) const double two63 = 2147483648.0 * 4294967296.0; UINT64 ret; if (val < two63) { +#ifdef _TARGET_XARCH_ ret = FastDbl2Lng(val); +#else +// In x86/x64, conversion result of negative double to unsigned integer is +// bit-equivalent unsigned value. +// But other architecture's compiler convert negative doubles to zero when +// the target is unsigned. + ret = UINT64(val); +#endif } else { // subtract 0x8000000000000000, do the convert then add it back again -- 2.7.4