summaryrefslogtreecommitdiffstats
path: root/contrib/compiler-rt/lib/builtins/floatditf.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/compiler-rt/lib/builtins/floatditf.c')
-rw-r--r--contrib/compiler-rt/lib/builtins/floatditf.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/contrib/compiler-rt/lib/builtins/floatditf.c b/contrib/compiler-rt/lib/builtins/floatditf.c
index 1a5f8e5..cd51dd8 100644
--- a/contrib/compiler-rt/lib/builtins/floatditf.c
+++ b/contrib/compiler-rt/lib/builtins/floatditf.c
@@ -27,19 +27,17 @@ COMPILER_RT_ABI fp_t __floatditf(di_int a) {
// All other cases begin by extracting the sign and absolute value of a
rep_t sign = 0;
- unsigned aAbs = (unsigned)a;
+ du_int aAbs = (du_int)a;
if (a < 0) {
sign = signBit;
- aAbs += 0x80000000;
+ aAbs = ~(du_int)a + 1U;
}
// Exponent of (fp_t)a is the width of abs(a).
- const int exponent = (aWidth - 1) - __builtin_clzll(a);
+ const int exponent = (aWidth - 1) - __builtin_clzll(aAbs);
rep_t result;
- // Shift a into the significand field and clear the implicit bit. Extra
- // cast to unsigned int is necessary to get the correct behavior for
- // the input INT_MIN.
+ // Shift a into the significand field, rounding if it is a right-shift
const int shift = significandBits - exponent;
result = (rep_t)aAbs << shift ^ implicitBit;
OpenPOWER on IntegriCloud