[llvm-commits] [llvm] r141820 - /llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp

Eli Friedman eli.friedman at gmail.com
Wed Oct 12 15:00:26 PDT 2011


Author: efriedma
Date: Wed Oct 12 17:00:26 2011
New Revision: 141820

URL: http://llvm.org/viewvc/llvm-project?rev=141820&view=rev
Log:
Fix a couple hash functions so that they do not depend on undefined shifts.  Based on patch by Ahmed Charles.


Modified:
    llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=141820&r1=141819&r2=141820&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Wed Oct 12 17:00:26 2011
@@ -92,7 +92,7 @@
   // 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;
+    Res ^= getHash(Inst->getOperand(i)) << (i & 0xF);
 
   if (CastInst *CI = dyn_cast<CastInst>(Inst))
     Res ^= getHash(CI->getType());
@@ -185,7 +185,7 @@
   for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i) {
     assert(!Inst->getOperand(i)->getType()->isMetadataTy() &&
            "Cannot value number calls with metadata operands");
-    Res ^= getHash(Inst->getOperand(i)) << i;
+    Res ^= getHash(Inst->getOperand(i)) << (i & 0xF);
   }
   
   // Mix in the opcode.





More information about the llvm-commits mailing list