diff options
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 1094a61cf1c..5ac98e1c127 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -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; } |