[llvm-commits] [llvm] r122727 - in /llvm/trunk: lib/Transforms/Scalar/EarlyCSE.cpp test/Transforms/EarlyCSE/basic.ll

Duncan Sands baldrick at free.fr
Mon Jan 3 10:52:33 PST 2011


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.

since you only need to hash in the pointer to the attributes, it would be
very cheap to do it.  There is no need to hash in each individual attribute.

Ciao, Duncan.



More information about the llvm-commits mailing list