[unroll] Don't use a map from pointer to bool. Use a set.

This is much more efficient. In particular, the query with the user
instruction has to insert a false for every missing instruction into the
set. This is just a cleanup a long the way to fixing the underlying
algorithm problems here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228994 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2015-02-13 00:29:39 +00:00
parent 37fc1833a8
commit 83fafb32fd

View File

@ -499,12 +499,12 @@ public:
unsigned estimateNumberOfDeadInsns() {
NumberOfOptimizedInstructions = 0;
SmallVector<Instruction *, 8> Worklist;
DenseMap<Instruction *, bool> DeadInstructions;
SmallPtrSet<Instruction *, 16> DeadInstructions;
// Start by initializing worklist with simplified instructions.
for (auto Folded : SimplifiedValues) {
if (auto FoldedInsn = dyn_cast<Instruction>(Folded.first)) {
Worklist.push_back(FoldedInsn);
DeadInstructions[FoldedInsn] = true;
DeadInstructions.insert(FoldedInsn);
}
}
// If a definition of an insn is only used by simplified or dead
@ -523,7 +523,7 @@ public:
bool AllUsersFolded = true;
for (auto U : I->users()) {
Instruction *UI = dyn_cast<Instruction>(U);
if (!SimplifiedValues[UI] && !DeadInstructions[UI]) {
if (!SimplifiedValues[UI] && !DeadInstructions.count(UI)) {
AllUsersFolded = false;
break;
}
@ -531,7 +531,7 @@ public:
if (AllUsersFolded) {
NumberOfOptimizedInstructions += TTI.getUserCost(I);
Worklist.push_back(I);
DeadInstructions[I] = true;
DeadInstructions.insert(I);
}
}
}