diff options
author | Stephen Canon <scanon@apple.com> | 2010-08-17 19:13:45 +0000 |
---|---|---|
committer | Stephen Canon <scanon@apple.com> | 2010-08-17 19:13:45 +0000 |
commit | 4d055d584cdc9c65e09092238a905c6f20b829ec (patch) | |
tree | 42a400f058cd189ce7679569ac1f625d1858fdb2 | |
parent | 86d0ba4286ec42dcd055bd22434c7f40009834bd (diff) | |
download | compiler-rt-4d055d584cdc9c65e09092238a905c6f20b829ec.tar.gz |
Adds an extra explicit cast to fix Bug 7931 and removes codepaths that were never used
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@111269 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/floatsidf.c | 16 | ||||
-rw-r--r-- | lib/floatunsidf.c | 14 |
2 files changed, 8 insertions, 22 deletions
diff --git a/lib/floatsidf.c b/lib/floatsidf.c index ebd1a6b60..a13ab8fbc 100644 --- a/lib/floatsidf.c +++ b/lib/floatsidf.c @@ -35,17 +35,11 @@ fp_t __floatsidf(int a) { const int exponent = (aWidth - 1) - __builtin_clz(a); rep_t result; - // Shift a into the significand field, rounding if it is a right-shift - if (exponent <= significandBits) { - const int shift = significandBits - exponent; - result = (rep_t)a << shift ^ implicitBit; - } else { - const int shift = exponent - significandBits; - result = (rep_t)a >> shift ^ implicitBit; - rep_t round = (rep_t)a << (typeWidth - shift); - if (round > signBit) result++; - if (round == signBit) result += result & 1; - } + // 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. + const int shift = significandBits - exponent; + result = (rep_t)(unsigned int)a << shift ^ implicitBit; // Insert the exponent result += (rep_t)(exponent + exponentBias) << significandBits; diff --git a/lib/floatunsidf.c b/lib/floatunsidf.c index 1342c3c45..05242c18a 100644 --- a/lib/floatunsidf.c +++ b/lib/floatunsidf.c @@ -27,17 +27,9 @@ fp_t __floatunsidf(unsigned int a) { const int exponent = (aWidth - 1) - __builtin_clz(a); rep_t result; - // Shift a into the significand field, rounding if it is a right-shift - if (exponent <= significandBits) { - const int shift = significandBits - exponent; - result = (rep_t)a << shift ^ implicitBit; - } else { - const int shift = exponent - significandBits; - result = (rep_t)a >> shift ^ implicitBit; - rep_t round = (rep_t)a << (typeWidth - shift); - if (round > signBit) result++; - if (round == signBit) result += result & 1; - } + // Shift a into the significand field and clear the implicit bit. + const int shift = significandBits - exponent; + result = (rep_t)a << shift ^ implicitBit; // Insert the exponent result += (rep_t)(exponent + exponentBias) << significandBits; |