[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
This commit is contained in:
Chandler Carruth 2015-02-13 04:27:50 +00:00
parent 361ac0df65
commit b9cb5b19d9

View File

@ -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<Instruction *, 8> Worklist;
SmallSetVector<Instruction *, 8> 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;