From: Chandler Carruth Date: Fri, 13 Feb 2015 04:27:50 +0000 (+0000) Subject: [unroll] Change the other worklist in the unroll analyzer to be a set X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=b9cb5b19d91ca570443e0dd09102bd611d36c4fc [unroll] Change the other worklist in the unroll analyzer to be a set vector. In addition to dramatically reducing the work required for contrived example loops, this also has to correct some serious latent bugs in the cost computation. Previously, we might add an instruction onto the worklist once for every load which it used and was simplified. Then we would visit it many times and accumulate "savings" each time. I mean, fortunately this couldn't matter for things like calls with 100s of operands, but even for binary operators this code seems like it must be double counting the savings. I just noticed this by inspection and due to the runtime problems it can introduce, I don't have any test cases for cases where the cost produced by this routine is unacceptable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229059 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index ccc4a248476..0851f436904 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -456,7 +456,7 @@ public: // values for the given Iteration. // Fill in SimplifiedValues map for future use in DCE-estimation. unsigned estimateNumberOfSimplifiedInstructions(unsigned Iteration) { - SmallVector Worklist; + SmallSetVector Worklist; SimplifiedValues.clear(); CountedInstructions.clear(); NumberOfOptimizedInstructions = 0; @@ -474,7 +474,7 @@ public: continue; if (!L->contains(UI)) continue; - Worklist.push_back(UI); + Worklist.insert(UI); } } @@ -491,7 +491,7 @@ public: continue; if (!L->contains(UI)) continue; - Worklist.push_back(UI); + Worklist.insert(UI); } } return NumberOfOptimizedInstructions;