diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-18 05:02:21 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-18 05:02:21 +0000 |
commit | 9eaef07519ddba4157dba5b7143a4c9c8a9175ce (patch) | |
tree | fcda3f7e4d7e34dcdc0589a47356dcfdb8fa7f8e | |
parent | a8a4f0db792b077adfbebfe41801c7dc9ebf23e8 (diff) | |
download | bcm5719-llvm-9eaef07519ddba4157dba5b7143a4c9c8a9175ce.tar.gz bcm5719-llvm-9eaef07519ddba4157dba5b7143a4c9c8a9175ce.zip |
[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
-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; } |