forked from OSchip/llvm-project
[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. llvm-svn: 228994
This commit is contained in:
parent
24fbdf124b
commit
10a9926ab5
|
@ -499,12 +499,12 @@ public:
|
||||||
unsigned estimateNumberOfDeadInsns() {
|
unsigned estimateNumberOfDeadInsns() {
|
||||||
NumberOfOptimizedInstructions = 0;
|
NumberOfOptimizedInstructions = 0;
|
||||||
SmallVector<Instruction *, 8> Worklist;
|
SmallVector<Instruction *, 8> Worklist;
|
||||||
DenseMap<Instruction *, bool> DeadInstructions;
|
SmallPtrSet<Instruction *, 16> DeadInstructions;
|
||||||
// Start by initializing worklist with simplified instructions.
|
// Start by initializing worklist with simplified instructions.
|
||||||
for (auto Folded : SimplifiedValues) {
|
for (auto Folded : SimplifiedValues) {
|
||||||
if (auto FoldedInsn = dyn_cast<Instruction>(Folded.first)) {
|
if (auto FoldedInsn = dyn_cast<Instruction>(Folded.first)) {
|
||||||
Worklist.push_back(FoldedInsn);
|
Worklist.push_back(FoldedInsn);
|
||||||
DeadInstructions[FoldedInsn] = true;
|
DeadInstructions.insert(FoldedInsn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If a definition of an insn is only used by simplified or dead
|
// If a definition of an insn is only used by simplified or dead
|
||||||
|
@ -523,7 +523,7 @@ public:
|
||||||
bool AllUsersFolded = true;
|
bool AllUsersFolded = true;
|
||||||
for (auto U : I->users()) {
|
for (auto U : I->users()) {
|
||||||
Instruction *UI = dyn_cast<Instruction>(U);
|
Instruction *UI = dyn_cast<Instruction>(U);
|
||||||
if (!SimplifiedValues[UI] && !DeadInstructions[UI]) {
|
if (!SimplifiedValues[UI] && !DeadInstructions.count(UI)) {
|
||||||
AllUsersFolded = false;
|
AllUsersFolded = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ public:
|
||||||
if (AllUsersFolded) {
|
if (AllUsersFolded) {
|
||||||
NumberOfOptimizedInstructions += TTI.getUserCost(I);
|
NumberOfOptimizedInstructions += TTI.getUserCost(I);
|
||||||
Worklist.push_back(I);
|
Worklist.push_back(I);
|
||||||
DeadInstructions[I] = true;
|
DeadInstructions.insert(I);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue