[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp

Owen Anderson resistor at mac.com
Tue Jun 19 16:07:38 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

GVNPRE.cpp updated: 1.41 -> 1.42
---
Log message:

Make dependsOnInvoke much more specific in what it tests, which in turn make it much faster to run.  This reduces the time to optimize lencondwith a debug build on PPC from ~450s to ~300s.


---
Diffs of the changes:  (+10 -42)

 GVNPRE.cpp |   52 ++++++++++------------------------------------------
 1 files changed, 10 insertions(+), 42 deletions(-)


Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.41 llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.42
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.41	Tue Jun 19 02:35:36 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp	Tue Jun 19 18:07:16 2007
@@ -504,40 +504,14 @@
 }
 
 bool GVNPRE::dependsOnInvoke(Value* V) {
-  if (!isa<User>(V))
-    return false;
-    
-  User* U = cast<User>(V);
-  std::map<User*, bool>::iterator I = invokeDep.find(U);
-  if (I != invokeDep.end())
-    return I->second;
-  
-  std::vector<Value*> worklist(U->op_begin(), U->op_end());
-  std::set<Value*> visited;
-  
-  while (!worklist.empty()) {
-    Value* current = worklist.back();
-    worklist.pop_back();
-    visited.insert(current);
-    
-    if (!isa<User>(current))
-      continue;
-    else if (isa<InvokeInst>(current))
-      return true;
-    
-    User* curr = cast<User>(current);
-    std::map<User*, bool>::iterator CI = invokeDep.find(curr);
-    if (CI != invokeDep.end()) {
-      if (CI->second)
+  if (PHINode* p = dyn_cast<PHINode>(V)) {
+    for (PHINode::op_iterator I = p->op_begin(), E = p->op_end(); I != E; ++I)
+      if (isa<InvokeInst>(*I))
         return true;
-    } else {
-      for (unsigned i = 0; i < curr->getNumOperands(); ++i)
-        if (visited.find(curr->getOperand(i)) == visited.end())
-          worklist.push_back(curr->getOperand(i));
-    }
+    return false;
+  } else {
+    return false;
   }
-  
-  return false;
 }
 
 // Remove all expressions whose operands are not themselves in the set
@@ -557,10 +531,6 @@
             lhsValid = true;
             break;
           }
-          
-      // Check for dependency on invoke insts
-      // NOTE: This check is expensive, so don't do it if we
-      // don't have to
       if (lhsValid)
         lhsValid = !dependsOnInvoke(BO->getOperand(0));
     
@@ -572,10 +542,6 @@
             rhsValid = true;
             break;
           }
-      
-      // Check for dependency on invoke insts
-      // NOTE: This check is expensive, so don't do it if we
-      // don't have to
       if (rhsValid)
         rhsValid = !dependsOnInvoke(BO->getOperand(1));
       
@@ -590,7 +556,8 @@
             lhsValid = true;
             break;
           }
-      lhsValid &= !dependsOnInvoke(C->getOperand(0));
+      if (lhsValid)
+        lhsValid = !dependsOnInvoke(C->getOperand(0));
       
       bool rhsValid = !isa<Instruction>(C->getOperand(1));
       if (!rhsValid)
@@ -600,7 +567,8 @@
           rhsValid = true;
           break;
         }
-      rhsValid &= !dependsOnInvoke(C->getOperand(1));
+      if (rhsValid)
+        rhsValid = !dependsOnInvoke(C->getOperand(1));
     
       if (!lhsValid || !rhsValid)
         set.erase(C);






More information about the llvm-commits mailing list