DenseMap<uintptr_t,...> doesn't allow all values as keys.
[oota-llvm.git] / lib / Transforms / Utils / Local.cpp
index 3f789fa865897ac6f5bb3593752aabbfbc432faf..32a50b80cd52bcd3abfe3ecb5439a3a253cc26c1 100644 (file)
@@ -632,6 +632,8 @@ bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) {
       Hash ^= reinterpret_cast<uintptr_t>(static_cast<Value *>(*I));
       Hash = (Hash << 7) | (Hash >> (sizeof(uintptr_t) * CHAR_BIT - 7));
     }
+    // Avoid colliding with the DenseMap sentinels ~0 and ~0-1.
+    Hash >>= 1;
     // If we've never seen this hash value before, it's a unique PHI.
     std::pair<DenseMap<uintptr_t, PHINode *>::iterator, bool> Pair =
       HashMap.insert(std::make_pair(Hash, PN));