diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp index a575c457553f..feebf1aede93 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -499,12 +499,12 @@ public: unsigned estimateNumberOfDeadInsns() { NumberOfOptimizedInstructions = 0; SmallVector Worklist; - DenseMap DeadInstructions; + SmallPtrSet DeadInstructions; // Start by initializing worklist with simplified instructions. for (auto Folded : SimplifiedValues) { if (auto FoldedInsn = dyn_cast(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(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); } } }