diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp --- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -547,7 +547,7 @@ void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI, InstSet &Dead) const { Dead.insert(MI); - auto IsDead = [this](MachineInstr *Def, int PhysReg) { + auto IsDead = [this, &Dead](MachineInstr *Def, int PhysReg) { unsigned LiveDefs = 0; for (auto &MO : Def->operands()) { if (!isValidRegDef(MO)) @@ -561,7 +561,10 @@ SmallPtrSet Uses; getGlobalUses(Def, PhysReg, Uses); - return Uses.size() == 1; + for (auto *Use : Uses) + if (!Dead.count(Use)) + return false; + return true; }; for (auto &MO : MI->operands()) { diff --git a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp --- a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp +++ b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp @@ -943,11 +943,8 @@ if (ModifiedITs.empty()) { LLVM_DEBUG(dbgs() << "ARM Loops: Will remove iteration count:\n"; for (auto *MI : Killed) - dbgs() << " - " << *MI; - for (auto *MI : DeadITs) dbgs() << " - " << *MI); LoLoop.ToRemove.insert(Killed.begin(), Killed.end()); - LoLoop.ToRemove.insert(DeadITs.begin(), DeadITs.end()); } // Collect and remove the users of iteration count.