diff options
author | Sam Parker <sam.parker@arm.com> | 2020-03-03 15:19:57 +0000 |
---|---|---|
committer | Sam Parker <sam.parker@arm.com> | 2020-03-03 15:23:05 +0000 |
commit | 5618e9be37502ede1b56a3ec1c809be461461c0e (patch) | |
tree | 59796fbc7988164b70f489c6c5e69111c78d4a69 /llvm/lib/CodeGen/ReachingDefAnalysis.cpp | |
parent | caf5a4d57fe0ac0ca8c8d45fd31e5dbbc6bb6bec (diff) | |
download | llvm-5618e9be37502ede1b56a3ec1c809be461461c0e.zip llvm-5618e9be37502ede1b56a3ec1c809be461461c0e.tar.gz llvm-5618e9be37502ede1b56a3ec1c809be461461c0e.tar.bz2 |
[RDA][ARM] collectKilledOperands across multiple blocks
Use MIOperand in collectLocalKilledOperands to make the search
global, as we already have to search for global uses too. This
allows us to delete more dead code when tail predicating.
Differential Revision: https://reviews.llvm.org/D75167
Diffstat (limited to 'llvm/lib/CodeGen/ReachingDefAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ReachingDefAnalysis.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp index 5f0b4a9..a1c0c21 100644 --- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -33,10 +33,6 @@ bool isValidRegUseOf(const MachineOperand &MO, int PhysReg) { return isValidRegUse(MO) && MO.getReg() == PhysReg; } -bool isKilledRegUse(const MachineOperand &MO) { - return isValidRegUse(MO) && MO.isKill(); -} - bool isValidRegDef(const MachineOperand &MO) { return isValidReg(MO) && MO.isDef(); } @@ -353,7 +349,7 @@ MachineInstr *ReachingDefAnalysis::getUniqueReachingMIDef(MachineInstr *MI, int PhysReg) const { // If there's a local def before MI, return it. MachineInstr *LocalDef = getReachingLocalMIDef(MI, PhysReg); - if (InstIds.lookup(LocalDef) < InstIds.lookup(MI)) + if (LocalDef && InstIds.lookup(LocalDef) < InstIds.lookup(MI)) return LocalDef; SmallPtrSet<MachineBasicBlock*, 4> VisitedBBs; @@ -544,8 +540,8 @@ ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, InstSet &Visited, return true; } -void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI, - InstSet &Dead) const { +void ReachingDefAnalysis::collectKilledOperands(MachineInstr *MI, + InstSet &Dead) const { Dead.insert(MI); auto IsDead = [this, &Dead](MachineInstr *Def, int PhysReg) { unsigned LiveDefs = 0; @@ -568,11 +564,11 @@ void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI, }; for (auto &MO : MI->operands()) { - if (!isKilledRegUse(MO)) + if (!isValidRegUse(MO)) continue; - if (MachineInstr *Def = getReachingLocalMIDef(MI, MO.getReg())) + if (MachineInstr *Def = getMIOperand(MI, MO)) if (IsDead(Def, MO.getReg())) - collectLocalKilledOperands(Def, Dead); + collectKilledOperands(Def, Dead); } } |