Fix unreachable return & simplify some branches.
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 1 Dec 2011 20:58:30 +0000 (20:58 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 1 Dec 2011 20:58:30 +0000 (20:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145627 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index 55cb433d8933a3a0906e6378511a28f68a3a6c86..506225f0640b7185ba4f14cd8c20a11cce468d40 100644 (file)
@@ -1440,15 +1440,11 @@ APInt APInt::sqrt() const {
   APInt nextSquare((x_old + 1) * (x_old +1));
   if (this->ult(square))
     return x_old;
-  else if (this->ule(nextSquare)) {
-    APInt midpoint((nextSquare - square).udiv(two));
-    APInt offset(*this - square);
-    if (offset.ult(midpoint))
-      return x_old;
-    else
-      return x_old + 1;
-  } else
-    llvm_unreachable("Error in APInt::sqrt computation");
+  assert(this->ule(nextSquare) && "Error in APInt::sqrt computation");
+  APInt midpoint((nextSquare - square).udiv(two));
+  APInt offset(*this - square);
+  if (offset.ult(midpoint))
+    return x_old;
   return x_old + 1;
 }