[PATCH] Fix float->uint conversion for inputs less than 0

Derek Schuff dschuff at google.com
Fri May 1 09:05:44 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9305

Files:
  compiler-rt/trunk/lib/builtins/fixunsdfdi.c
  compiler-rt/trunk/lib/builtins/fixunsdfti.c
  compiler-rt/trunk/lib/builtins/fixunssfdi.c

Index: compiler-rt/trunk/lib/builtins/fixunsdfdi.c
===================================================================
--- compiler-rt/trunk/lib/builtins/fixunsdfdi.c
+++ compiler-rt/trunk/lib/builtins/fixunsdfdi.c
@@ -21,6 +21,7 @@
 COMPILER_RT_ABI du_int
 __fixunsdfdi(double a)
 {
+    if (a <= 0.0) return 0;
     su_int high = a/0x1p32f;
     su_int low = a - (double)high*0x1p32f;
     return ((du_int)high << 32) | low;
Index: compiler-rt/trunk/lib/builtins/fixunsdfti.c
===================================================================
--- compiler-rt/trunk/lib/builtins/fixunsdfti.c
+++ compiler-rt/trunk/lib/builtins/fixunsdfti.c
@@ -17,7 +17,7 @@
 #include "fp_fixuint_impl.inc"
 
 COMPILER_RT_ABI tu_int
-__fixunsdftti(fp_t a) {
+__fixunsdfti(fp_t a) {
     return __fixuint(a);
 }
 #endif /* CRT_HAS_128BIT */
Index: compiler-rt/trunk/lib/builtins/fixunssfdi.c
===================================================================
--- compiler-rt/trunk/lib/builtins/fixunssfdi.c
+++ compiler-rt/trunk/lib/builtins/fixunssfdi.c
@@ -21,6 +21,7 @@
 COMPILER_RT_ABI du_int
 __fixunssfdi(float a)
 {
+    if (a <= 0.0f) return 0;
     double da = a;
     su_int high = da/0x1p32f;
     su_int low = da - (double)high*0x1p32f;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9305.24807.patch
Type: text/x-patch
Size: 1234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150501/2b53d140/attachment.bin>


More information about the llvm-commits mailing list