[llvm-commits] [llvm] r136222 - /llvm/trunk/lib/Support/BlockFrequency.cpp
Jakub Staszak
jstaszak at apple.com
Wed Jul 27 09:00:41 PDT 2011
Author: kuba
Date: Wed Jul 27 11:00:40 2011
New Revision: 136222
URL: http://llvm.org/viewvc/llvm-project?rev=136222&view=rev
Log:
Optimize 96-bit division a little bit.
Modified:
llvm/trunk/lib/Support/BlockFrequency.cpp
Modified: llvm/trunk/lib/Support/BlockFrequency.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/BlockFrequency.cpp?rev=136222&r1=136221&r2=136222&view=diff
==============================================================================
--- llvm/trunk/lib/Support/BlockFrequency.cpp (original)
+++ llvm/trunk/lib/Support/BlockFrequency.cpp Wed Jul 27 11:00:40 2011
@@ -46,8 +46,9 @@
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 @@
}
}
- return y;
+ return y << (64 - i + 1);
}
}
More information about the llvm-commits
mailing list