[llvm-commits] [llvm] r51035 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Tue May 13 06:41:38 PDT 2008


Author: resistor
Date: Tue May 13 08:41:23 2008
New Revision: 51035

URL: http://llvm.org/viewvc/llvm-project?rev=51035&view=rev
Log:
Make the non-local CSE safety checks slightly more thorough.

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

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=51035&r1=51034&r2=51035&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue May 13 08:41:23 2008
@@ -443,7 +443,7 @@
       
       DenseMap<BasicBlock*, Value*> deps;
       MD->getNonLocalDependency(C, deps);
-      Value* dep = 0;
+      CallInst* cdep = 0;
       
       for (DenseMap<BasicBlock*, Value*>::iterator I = deps.begin(),
            E = deps.end(); I != E; ++I) {
@@ -453,22 +453,24 @@
           return nextValueNumber++;
         } else if (I->second != MemoryDependenceAnalysis::NonLocal) {
           if (DT->dominates(I->first, C->getParent())) {
-            dep = I->second;
+            if (CallInst* CD = dyn_cast<CallInst>(I->second))
+              cdep = CD;
+            else {
+              valueNumbering.insert(std::make_pair(V, nextValueNumber));
+              return nextValueNumber++;
+            }
           } else {
             valueNumbering.insert(std::make_pair(V, nextValueNumber));
-
             return nextValueNumber++;
           }
         }
       }
       
-      if (!dep || !isa<CallInst>(dep)) {
+      if (!cdep) {
         valueNumbering.insert(std::make_pair(V, nextValueNumber));
         return nextValueNumber++;
       }
       
-      CallInst* cdep = cast<CallInst>(dep);
-      
       if (cdep->getCalledFunction() != C->getCalledFunction() ||
           cdep->getNumOperands() != C->getNumOperands()) {
         valueNumbering.insert(std::make_pair(V, nextValueNumber));





More information about the llvm-commits mailing list