From dfe8f5da4c707c447b80ff5bf78313b35621d9c4 Mon Sep 17 00:00:00 2001 From: Sam Parker Date: Thu, 27 Feb 2020 10:54:08 +0000 Subject: [PATCH] [ARM][RDA] Allow multiple killed users In RDA, check against the already decided dead instructions when looking at users. This allows an instruction to be removed if it has multiple users, but they're all dead. This means that IT instructions can be considered killed once all the itstate using instructions are dead. Differential Revision: https://reviews.llvm.org/D75245 --- llvm/lib/CodeGen/ReachingDefAnalysis.cpp | 7 +++++-- llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp index 84029a0..5f0b4a9 100644 --- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -547,7 +547,7 @@ ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, InstSet &Visited, 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 @@ void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI, 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 index 2a2179f..92eb2e2 100644 --- a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp +++ b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp @@ -943,11 +943,8 @@ void ARMLowOverheadLoops::IterationCountDCE(LowOverheadLoop &LoLoop) { 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. -- 2.7.4