Fix APFloat::getLargest so that it actually returns the correct value. Found by...
[oota-llvm.git] / lib / Support / APFloat.cpp
index 5307829ed83b2208eb19006debb701c5a3a2c45e..95df8617fb5c4ead5a87c1ad4c73df0c0427c343 100644 (file)
@@ -3243,8 +3243,9 @@ APFloat APFloat::getLargest(const fltSemantics &Sem, bool Negative) {
     significand[i] = ~((integerPart) 0);
 
   // ...and then clear the top bits for internal consistency.
-  significand[N-1] &=
-    (((integerPart) 1) << ((Sem.precision % integerPartWidth) - 1)) - 1;
+  if (Sem.precision % integerPartWidth != 0)
+    significand[N-1] &=
+      (((integerPart) 1) << (Sem.precision % integerPartWidth)) - 1;
 
   return Val;
 }