[APInt] Cleanup the reverseBits slow case a little.

Use lshrInPlace. Use single bit extract and operator|=(uint64_t) to avoid a few temporary APInts.

llvm-svn: 300527
This commit is contained in:
Craig Topper 2017-04-18 05:02:21 +00:00
parent a8a4f0db79
commit 9eaef07519
1 changed files with 4 additions and 6 deletions

View File

@ -774,14 +774,12 @@ APInt APInt::reverseBits() const {
}
APInt Val(*this);
APInt Reversed(*this);
int S = BitWidth - 1;
APInt Reversed(BitWidth, 0);
unsigned S = BitWidth;
const APInt One(BitWidth, 1);
for ((Val = Val.lshr(1)); Val != 0; (Val = Val.lshr(1))) {
for (; Val != 0; Val.lshrInPlace(1)) {
Reversed <<= 1;
Reversed |= (Val & One);
Reversed |= Val[0];
--S;
}