diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-28 21:51:18 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-28 21:51:18 +0000 |
commit | 5d3257e37ced7dd75023bb9c4619f297374f61d6 (patch) | |
tree | 2bece9af5caaf7bf70fc9af3b948f476ab1c93d0 /lib/Support | |
parent | 9e638df937b66e4313445163e069623b72b86f9a (diff) | |
download | external_llvm-5d3257e37ced7dd75023bb9c4619f297374f61d6.zip external_llvm-5d3257e37ced7dd75023bb9c4619f297374f61d6.tar.gz external_llvm-5d3257e37ced7dd75023bb9c4619f297374f61d6.tar.bz2 |
Fix a bad overflow check pointed out by Ben.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185226 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/BlockFrequency.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Support/BlockFrequency.cpp b/lib/Support/BlockFrequency.cpp index 8de517f..5e45e46 100644 --- a/lib/Support/BlockFrequency.cpp +++ b/lib/Support/BlockFrequency.cpp @@ -47,9 +47,7 @@ static uint64_t div96bit(uint64_t W[2], uint32_t D) { uint64_t x = W[1]; unsigned i; - // This is really a 64-bit division. - if (!x) - return y / D; + assert(x != 0 && "This is really a 64-bit division"); // This long division algorithm automatically saturates on overflow. for (i = 0; i < 64 && x; ++i) { @@ -75,7 +73,7 @@ void BlockFrequency::scale(uint32_t N, uint32_t D) { uint64_t MulRes = (MulHi << 32) + MulLo; // If the product fits in 64 bits, just use built-in division. - if (MulHi <= UINT32_MAX && MulRes <= MulLo) { + if (MulHi <= UINT32_MAX && MulRes >= MulLo) { Frequency = MulRes / D; return; } |