summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-05-10 07:50:15 +0000
committerCraig Topper <craig.topper@gmail.com>2017-05-10 07:50:15 +0000
commit62de039bd1123aaea4abbfa85ab17ce739f046ec (patch)
tree797b87e45590090f381ecbd3043514d39ac608a9 /llvm/lib/Support/APInt.cpp
parentfc9213e0e518fd3302ce79c29e302455871b764b (diff)
downloadbcm5719-llvm-62de039bd1123aaea4abbfa85ab17ce739f046ec.tar.gz
bcm5719-llvm-62de039bd1123aaea4abbfa85ab17ce739f046ec.zip
[APInt] Use getNumWords function in udiv/urem/udivrem instead of reimplementinging it.
llvm-svn: 302625
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 3bfd6ba5ec7..99a7b18b173 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -1578,11 +1578,9 @@ APInt APInt::udiv(const APInt& RHS) const {
}
// Get some facts about the LHS and RHS number of bits and words
- unsigned rhsBits = RHS.getActiveBits();
- unsigned rhsWords = !rhsBits ? 0 : (APInt::whichWord(rhsBits - 1) + 1);
+ unsigned rhsWords = getNumWords(RHS.getActiveBits());
assert(rhsWords && "Divided by zero???");
- unsigned lhsBits = this->getActiveBits();
- unsigned lhsWords = !lhsBits ? 0 : (APInt::whichWord(lhsBits - 1) + 1);
+ unsigned lhsWords = getNumWords(getActiveBits());
// Deal with some degenerate cases
if (!lhsWords)
@@ -1623,12 +1621,10 @@ APInt APInt::urem(const APInt& RHS) const {
}
// Get some facts about the LHS
- unsigned lhsBits = getActiveBits();
- unsigned lhsWords = !lhsBits ? 0 : (whichWord(lhsBits - 1) + 1);
+ unsigned lhsWords = getNumWords(getActiveBits());
// Get some facts about the RHS
- unsigned rhsBits = RHS.getActiveBits();
- unsigned rhsWords = !rhsBits ? 0 : (APInt::whichWord(rhsBits - 1) + 1);
+ unsigned rhsWords = getNumWords(RHS.getActiveBits());
assert(rhsWords && "Performing remainder operation by zero ???");
// Check the degenerate cases
@@ -1677,10 +1673,8 @@ void APInt::udivrem(const APInt &LHS, const APInt &RHS,
}
// Get some size facts about the dividend and divisor
- unsigned lhsBits = LHS.getActiveBits();
- unsigned lhsWords = !lhsBits ? 0 : (APInt::whichWord(lhsBits - 1) + 1);
- unsigned rhsBits = RHS.getActiveBits();
- unsigned rhsWords = !rhsBits ? 0 : (APInt::whichWord(rhsBits - 1) + 1);
+ unsigned lhsWords = getNumWords(LHS.getActiveBits());
+ unsigned rhsWords = getNumWords(RHS.getActiveBits());
// Check the degenerate cases
if (lhsWords == 0) {
OpenPOWER on IntegriCloud