[llvm-commits] [compiler-rt] r111269 - in /compiler-rt/trunk/lib: floatsidf.c floatunsidf.c

Stephen Canon scanon at apple.com
Tue Aug 17 12:13:45 PDT 2010


Author: scanon
Date: Tue Aug 17 14:13:45 2010
New Revision: 111269

URL: http://llvm.org/viewvc/llvm-project?rev=111269&view=rev
Log:
Adds an extra explicit cast to fix Bug 7931 and removes codepaths that were never used

Modified:
    compiler-rt/trunk/lib/floatsidf.c
    compiler-rt/trunk/lib/floatunsidf.c

Modified: compiler-rt/trunk/lib/floatsidf.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/floatsidf.c?rev=111269&r1=111268&r2=111269&view=diff
==============================================================================
--- compiler-rt/trunk/lib/floatsidf.c (original)
+++ compiler-rt/trunk/lib/floatsidf.c Tue Aug 17 14:13:45 2010
@@ -35,17 +35,11 @@
     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;

Modified: compiler-rt/trunk/lib/floatunsidf.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/floatunsidf.c?rev=111269&r1=111268&r2=111269&view=diff
==============================================================================
--- compiler-rt/trunk/lib/floatunsidf.c (original)
+++ compiler-rt/trunk/lib/floatunsidf.c Tue Aug 17 14:13:45 2010
@@ -27,17 +27,9 @@
     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;





More information about the llvm-commits mailing list