[llvm] r228994 - [unroll] Don't use a map from pointer to bool. Use a set.
Chandler Carruth
chandlerc at gmail.com
Thu Feb 12 16:29:39 PST 2015
Author: chandlerc
Date: Thu Feb 12 18:29:39 2015
New Revision: 228994
URL: http://llvm.org/viewvc/llvm-project?rev=228994&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=228994&r1=228993&r2=228994&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Thu Feb 12 18:29:39 2015
@@ -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);
}
}
}
More information about the llvm-commits
mailing list