aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2011-12-01 20:58:30 +0000
committerDavid Blaikie <dblaikie@gmail.com>2011-12-01 20:58:30 +0000
commit18c7ec1344b14c9a483b89f7ee73fba1cbdb2a38 (patch)
tree71a160448fbd404796dad4070e9ef4e35c6b116d /lib/Support
parentcb497b888aabebe13de431c8a6e7c7d31f4dea0c (diff)
downloadexternal_llvm-18c7ec1344b14c9a483b89f7ee73fba1cbdb2a38.zip
external_llvm-18c7ec1344b14c9a483b89f7ee73fba1cbdb2a38.tar.gz
external_llvm-18c7ec1344b14c9a483b89f7ee73fba1cbdb2a38.tar.bz2
Fix unreachable return & simplify some branches.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/APInt.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 55cb433..506225f 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -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;
}