diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-28 21:10:25 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-28 21:10:25 +0000 |
commit | c7e503f2e2038d9b94e52d256de8c2b8ab22cd2f (patch) | |
tree | bbe2aed8b372311c74d5039650ab2f0939b4a8de /llvm/lib/Support/BlockFrequency.cpp | |
parent | 0d5510458e6a5e9810f87df90e1c83a2a21b94cf (diff) | |
download | bcm5719-llvm-c7e503f2e2038d9b94e52d256de8c2b8ab22cd2f.tar.gz bcm5719-llvm-c7e503f2e2038d9b94e52d256de8c2b8ab22cd2f.zip |
Eliminate an assortment of undefined behavior.
Hopefully, this fixes the PPC64 buildbots.
llvm-svn: 185218
Diffstat (limited to 'llvm/lib/Support/BlockFrequency.cpp')
-rw-r--r-- | llvm/lib/Support/BlockFrequency.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Support/BlockFrequency.cpp b/llvm/lib/Support/BlockFrequency.cpp index 6e4d6b1b33c..8de517fad64 100644 --- a/llvm/lib/Support/BlockFrequency.cpp +++ b/llvm/lib/Support/BlockFrequency.cpp @@ -47,9 +47,13 @@ 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; + // This long division algorithm automatically saturates on overflow. for (i = 0; i < 64 && x; ++i) { - uint32_t t = (int)x >> 31; + uint32_t t = -((x >> 31) & 1); // Splat bit 31 to bits 0-31. x = (x << 1) | (y >> 63); y = y << 1; if ((x | t) >= D) { |