[llvm-commits] [llvm] r135992 - in /llvm/trunk: include/llvm/Support/BlockFrequency.h lib/Support/BlockFrequency.cpp lib/Support/CMakeLists.txt
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Jul 25 15:44:26 PDT 2011
On Jul 25, 2011, at 3:24 PM, Jakub Staszak wrote:
> --- llvm/trunk/include/llvm/Support/BlockFrequency.h (added)
> +++ llvm/trunk/include/llvm/Support/BlockFrequency.h Mon Jul 25 17:24:51 2011
> @@ -0,0 +1,64 @@
> + static void mult96bit(uint64_t freq, uint32_t N, uint64_t W[2]);
> + static uint64_t div96bit(uint64_t W[2], uint32_t D);
These functions should not be in the header, they can be static functions in the .cpp file.
> +/// div96bit - Divide 96-bit value stored in W array by D. Return 64-bit frequency.
> +uint64_t BlockFrequency::div96bit(uint64_t W[2], uint32_t D) {
> + uint64_t y = W[0];
> + uint64_t x = W[1];
> +
> + for (int i = 1; i <= 64; ++i) {
> + uint32_t t = (int)x >> 31;
> + x = (x << 1) | (y >> 63);
> + y = y << 1;
> + if ((x | t) >= D) {
> + x -= D;
> + ++y;
> + }
> + }
> +
> + return y;
> +}
There has to be a faster way to divide two numbers than this.
Please also compare the performance of these routines to the same computations in floating point.
/jakob
More information about the llvm-commits
mailing list