From: Owen Anderson Date: Tue, 19 Jun 2007 23:07:16 +0000 (+0000) Subject: Make dependsOnInvoke much more specific in what it tests, which in turn make it much... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=52471b102c89d6d7ac18f3e8c155843a0ea9f6ec;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37667 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp index 15fecca0d8d..61bc3673cf5 100644 --- a/lib/Transforms/Scalar/GVNPRE.cpp +++ b/lib/Transforms/Scalar/GVNPRE.cpp @@ -504,40 +504,14 @@ void GVNPRE::phi_translate_set(std::set& anticIn, } bool GVNPRE::dependsOnInvoke(Value* V) { - if (!isa(V)) - return false; - - User* U = cast(V); - std::map::iterator I = invokeDep.find(U); - if (I != invokeDep.end()) - return I->second; - - std::vector worklist(U->op_begin(), U->op_end()); - std::set visited; - - while (!worklist.empty()) { - Value* current = worklist.back(); - worklist.pop_back(); - visited.insert(current); - - if (!isa(current)) - continue; - else if (isa(current)) - return true; - - User* curr = cast(current); - std::map::iterator CI = invokeDep.find(curr); - if (CI != invokeDep.end()) { - if (CI->second) + if (PHINode* p = dyn_cast(V)) { + for (PHINode::op_iterator I = p->op_begin(), E = p->op_end(); I != E; ++I) + if (isa(*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 @@ void GVNPRE::clean(std::set& set) { 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 @@ void GVNPRE::clean(std::set& set) { 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 @@ void GVNPRE::clean(std::set& set) { lhsValid = true; break; } - lhsValid &= !dependsOnInvoke(C->getOperand(0)); + if (lhsValid) + lhsValid = !dependsOnInvoke(C->getOperand(0)); bool rhsValid = !isa(C->getOperand(1)); if (!rhsValid) @@ -600,7 +567,8 @@ void GVNPRE::clean(std::set& set) { rhsValid = true; break; } - rhsValid &= !dependsOnInvoke(C->getOperand(1)); + if (rhsValid) + rhsValid = !dependsOnInvoke(C->getOperand(1)); if (!lhsValid || !rhsValid) set.erase(C);