fix for correct conversion from negative double to unsigned long in ARM (modify helper)
authorHyeongseok Oh <hseok82.oh@smasung.com>
Fri, 19 Aug 2016 02:06:52 +0000 (11:06 +0900)
committerHyeongseok Oh <hseok82.oh@smasung.com>
Fri, 19 Aug 2016 02:06:52 +0000 (11:06 +0900)
Commit migrated from https://github.com/dotnet/coreclr/commit/39302ecfa7a32bb39d30e299a1863d0af59c31c5

src/coreclr/src/vm/jithelpers.cpp

index 1f7c630..0f05342 100644 (file)
@@ -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