Index: llvm/lib/CodeGen/ReachingDefAnalysis.cpp =================================================================== --- llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -523,7 +523,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 (!MO.isReg() || !MO.getReg() || MO.isUse()) @@ -537,7 +537,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()) { Index: llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp =================================================================== --- llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp +++ 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.