[llvm] r302625 - [APInt] Use getNumWords function in udiv/urem/udivrem instead of reimplementinging it.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 00:50:15 PDT 2017
Author: ctopper
Date: Wed May 10 02:50:15 2017
New Revision: 302625
URL: http://llvm.org/viewvc/llvm-project?rev=302625&view=rev
Log:
[APInt] Use getNumWords function in udiv/urem/udivrem instead of reimplementinging it.
Modified:
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=302625&r1=302624&r2=302625&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Wed May 10 02:50:15 2017
@@ -1578,11 +1578,9 @@ APInt APInt::udiv(const APInt& RHS) cons
}
// 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) cons
}
// 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, co
}
// 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) {
More information about the llvm-commits
mailing list