From 9b8a6a3b2b28dbe84f9e25d1b5c4832da372a96f Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Wed, 27 Jul 2011 16:00:40 +0000 Subject: Optimize 96-bit division a little bit. llvm-svn: 136222 --- llvm/lib/Support/BlockFrequency.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Support/BlockFrequency.cpp') diff --git a/llvm/lib/Support/BlockFrequency.cpp b/llvm/lib/Support/BlockFrequency.cpp index 0bc78408104..a63bf83f203 100644 --- a/llvm/lib/Support/BlockFrequency.cpp +++ b/llvm/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); } } -- cgit v1.2.3