aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-28 21:10:25 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-28 21:10:25 +0000
commite187512bde9fd090a78924928a0b8793e3d87cbb (patch)
tree81b77a6ae98b1c6879123b9ba3cbf23960b09dc5 /lib/Support
parent4025fa5b85cf7e3df47c40c2a03e05afe44841fa (diff)
downloadexternal_llvm-e187512bde9fd090a78924928a0b8793e3d87cbb.zip
external_llvm-e187512bde9fd090a78924928a0b8793e3d87cbb.tar.gz
external_llvm-e187512bde9fd090a78924928a0b8793e3d87cbb.tar.bz2
Eliminate an assortment of undefined behavior.
Hopefully, this fixes the PPC64 buildbots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/BlockFrequency.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Support/BlockFrequency.cpp b/lib/Support/BlockFrequency.cpp
index 6e4d6b1..8de517f 100644
--- a/lib/Support/BlockFrequency.cpp
+++ b/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) {