aboutsummaryrefslogtreecommitdiff
path: root/lib/builtins/floatsitf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/builtins/floatsitf.c')
-rw-r--r--lib/builtins/floatsitf.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/builtins/floatsitf.c b/lib/builtins/floatsitf.c
index 85346933f81e..f0abca363b5e 100644
--- a/lib/builtins/floatsitf.c
+++ b/lib/builtins/floatsitf.c
@@ -30,16 +30,14 @@ COMPILER_RT_ABI fp_t __floatsitf(int a) {
unsigned aAbs = (unsigned)a;
if (a < 0) {
sign = signBit;
- aAbs += 0x80000000;
+ aAbs = ~(unsigned)a + 1U;
}
// Exponent of (fp_t)a is the width of abs(a).
- const int exponent = (aWidth - 1) - __builtin_clz(a);
+ const int exponent = (aWidth - 1) - __builtin_clz(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 and clear the implicit bit.
const int shift = significandBits - exponent;
result = (rep_t)aAbs << shift ^ implicitBit;