Fix the construction of the magic constant for roundToIntegral to be 64-bit safe...
authorOwen Anderson <resistor@mac.com>
Tue, 14 Aug 2012 18:51:15 +0000 (18:51 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 14 Aug 2012 18:51:15 +0000 (18:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161885 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APFloat.cpp

index 2139df56205b8c8ea9080c8772ff2a0d45f04e9b..5ea75a621ad2cd40872e1f52353415cb29c5c510 100644 (file)
@@ -1774,8 +1774,8 @@ APFloat::opStatus APFloat::roundToIntegral(roundingMode rounding_mode) {
   // precision of our format, and then subtract it back off again.  The choice
   // of rounding modes for the addition/subtraction determines the rounding mode
   // for our integral rounding as well.
-  APInt IntegerConstant(NextPowerOf2(semanticsPrecision(*semantics)),
-                        1 << (semanticsPrecision(*semantics)-1));
+  APInt IntegerConstant(NextPowerOf2(semanticsPrecision(*semantics)), 1);
+  IntegerConstant <<= semanticsPrecision(*semantics)-1;
   APFloat MagicConstant(*semantics);
   fs = MagicConstant.convertFromAPInt(IntegerConstant, false,
                                       rmNearestTiesToEven);