[llvm-commits] [llvm] r122727 - in /llvm/trunk: lib/Transforms/Scalar/EarlyCSE.cpp test/Transforms/EarlyCSE/basic.ll
Chris Lattner
clattner at apple.com
Mon Jan 3 10:47:55 PST 2011
On Jan 3, 2011, at 4:43 AM, Duncan Sands wrote:
> Hi Chris,
>
>> +unsigned DenseMapInfo<MemoryValue>::getHashValue(MemoryValue Val) {
>> + Instruction *Inst = Val.Inst;
>> + // Hash in all of the operands as pointers.
>> + unsigned Res = 0;
>> + for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
>> + Res ^= getHash(Inst->getOperand(i))<< i;
>> + // Mix in the opcode.
>> + return (Res<< 1) ^ Inst->getOpcode();
>> +}
>
> for calls you could also hash in the attributes.
The attributes for calls with identical arguments are almost always the same. This would just make the hash slower without reducing collisions IMO.
-Chris
More information about the llvm-commits
mailing list