[llvm] r234425 - Eliminate O(n^2) worst-case behavior in SSA construction
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Apr 9 08:45:09 PDT 2015
Maybe add a testcase with a ladder graph that is now fast but used to
take a noticeable amount of time?
On 8 April 2015 at 14:26, Cameron Zwarich <zwarich at apple.com> wrote:
> Author: zwarich
> Date: Wed Apr 8 13:26:20 2015
> New Revision: 234425
>
> URL: http://llvm.org/viewvc/llvm-project?rev=234425&view=rev
> Log:
> Eliminate O(n^2) worst-case behavior in SSA construction
>
> The code uses a priority queue and a worklist, which share the same
> visited set, but the visited set is only updated when inserting into
> the priority queue. Instead, switch to using separate visited sets
> for the priority queue and worklist.
>
> Modified:
> llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
>
> Modified: llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp?rev=234425&r1=234424&r2=234425&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
> +++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Wed Apr 8 13:26:20 2015
> @@ -872,8 +872,10 @@ void PromoteMem2Reg::DetermineInsertionP
> }
>
> SmallVector<std::pair<unsigned, BasicBlock *>, 32> DFBlocks;
> - SmallPtrSet<DomTreeNode *, 32> Visited;
> SmallVector<DomTreeNode *, 32> Worklist;
> + SmallPtrSet<DomTreeNode *, 32> VisitedPQ;
> + SmallPtrSet<DomTreeNode *, 32> VisitedWorklist;
> +
> while (!PQ.empty()) {
> DomTreeNodePair RootPair = PQ.top();
> PQ.pop();
> @@ -887,6 +889,7 @@ void PromoteMem2Reg::DetermineInsertionP
>
> Worklist.clear();
> Worklist.push_back(Root);
> + VisitedWorklist.insert(Root);
>
> while (!Worklist.empty()) {
> DomTreeNode *Node = Worklist.pop_back_val();
> @@ -905,7 +908,7 @@ void PromoteMem2Reg::DetermineInsertionP
> if (SuccLevel > RootLevel)
> continue;
>
> - if (!Visited.insert(SuccNode).second)
> + if (!VisitedPQ.insert(SuccNode).second)
> continue;
>
> BasicBlock *SuccBB = SuccNode->getBlock();
> @@ -919,7 +922,7 @@ void PromoteMem2Reg::DetermineInsertionP
>
> for (DomTreeNode::iterator CI = Node->begin(), CE = Node->end(); CI != CE;
> ++CI) {
> - if (!Visited.count(*CI))
> + if (VisitedWorklist.insert(*CI).second)
> Worklist.push_back(*CI);
> }
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list