[compiler-rt] r236319 - Fix float->uint conversion for inputs less than 0
Derek Schuff
dschuff at google.com
Fri May 1 09:02:16 PDT 2015
Author: dschuff
Date: Fri May 1 11:02:16 2015
New Revision: 236319
URL: http://llvm.org/viewvc/llvm-project?rev=236319&view=rev
Log:
Fix float->uint conversion for inputs less than 0
Summary:
The spec for these functions says that they should return 0 in this case but
this regressed in r234148. That revision essentially delegates the conversion
to the hardware, but that has different behavior on different platforms (e.g.
it is wrong on x86).
Also fix a typo in the name of __fixunsdfti
Test Plan: The existing unit tests now pass
Reviewers: joerg, howard.hinnant
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9305
Modified:
compiler-rt/trunk/lib/builtins/fixunsdfdi.c
compiler-rt/trunk/lib/builtins/fixunsdfti.c
compiler-rt/trunk/lib/builtins/fixunssfdi.c
Modified: compiler-rt/trunk/lib/builtins/fixunsdfdi.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/fixunsdfdi.c?rev=236319&r1=236318&r2=236319&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/fixunsdfdi.c (original)
+++ compiler-rt/trunk/lib/builtins/fixunsdfdi.c Fri May 1 11:02:16 2015
@@ -21,6 +21,7 @@ ARM_EABI_FNALIAS(d2ulz, fixunsdfdi)
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;
Modified: compiler-rt/trunk/lib/builtins/fixunsdfti.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/fixunsdfti.c?rev=236319&r1=236318&r2=236319&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/fixunsdfti.c (original)
+++ compiler-rt/trunk/lib/builtins/fixunsdfti.c Fri May 1 11:02:16 2015
@@ -17,7 +17,7 @@ typedef tu_int fixuint_t;
#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 */
Modified: compiler-rt/trunk/lib/builtins/fixunssfdi.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/fixunssfdi.c?rev=236319&r1=236318&r2=236319&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/fixunssfdi.c (original)
+++ compiler-rt/trunk/lib/builtins/fixunssfdi.c Fri May 1 11:02:16 2015
@@ -21,6 +21,7 @@ ARM_EABI_FNALIAS(f2ulz, fixunssfdi)
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;
More information about the llvm-commits
mailing list