diff options
author | Jakub Staszak <jstaszak@apple.com> | 2011-07-27 16:00:40 +0000 |
---|---|---|
committer | Jakub Staszak <jstaszak@apple.com> | 2011-07-27 16:00:40 +0000 |
commit | ffcc2a542c13b698848f38c56a13cdac388c65ab (patch) | |
tree | 3bd86c582f1d92d481093e68a1c342d0d58be5c5 | |
parent | 636a02b57c3ade2eb528bda31f05556f42aa7d48 (diff) |
Optimize 96-bit division a little bit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136222 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Support/BlockFrequency.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Support/BlockFrequency.cpp b/lib/Support/BlockFrequency.cpp index 0bc7840810..a63bf83f20 100644 --- a/lib/Support/BlockFrequency.cpp +++ b/lib/Support/BlockFrequency.cpp @@ -46,8 +46,9 @@ void mult96bit(uint64_t freq, uint32_t N, uint64_t W[2]) { uint64_t div96bit(uint64_t W[2], uint32_t D) { uint64_t y = W[0]; uint64_t x = W[1]; + int i; - for (int i = 1; i <= 64; ++i) { + for (i = 1; i <= 64 && x; ++i) { uint32_t t = (int)x >> 31; x = (x << 1) | (y >> 63); y = y << 1; @@ -57,7 +58,7 @@ uint64_t div96bit(uint64_t W[2], uint32_t D) { } } - return y; + return y << (64 - i + 1); } } |