aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
diff options
context:
space:
mode:
authorSam Parker <sam.parker@arm.com>2020-02-24 13:50:46 +0000
committerSam Parker <sam.parker@arm.com>2020-02-24 13:51:03 +0000
commita67eb221e2281350eeab5dd4b9119895c500674c (patch)
tree865cdbcb7768f895f8cafe7815b57ab291de4856 /llvm/lib/CodeGen/ReachingDefAnalysis.cpp
parentbd5b22070b6984d89c13b6cf38c3e54fc98ce291 (diff)
downloadllvm-a67eb221e2281350eeab5dd4b9119895c500674c.zip
llvm-a67eb221e2281350eeab5dd4b9119895c500674c.tar.gz
llvm-a67eb221e2281350eeab5dd4b9119895c500674c.tar.bz2
[RDA][ARM][LowOverheadLoops] Iteration count IT blocks
Change the way that we remove the redundant iteration count code in the presence of IT blocks. collectLocalKilledOperands has been introduced to scan an instructions operands, collecting the killed instructions and then visiting them too. This is used to delete the code in the preheader which calculates the iteration count. We also track any IT blocks within the preheader and, if we remove all the instructions from the IT block, we also remove the IT instruction. isSafeToRemove is used to remove any redundant uses of the iteration count within the loop body. Differential Revision: https://reviews.llvm.org/D74975
Diffstat (limited to 'llvm/lib/CodeGen/ReachingDefAnalysis.cpp')
-rw-r--r--llvm/lib/CodeGen/ReachingDefAnalysis.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index c14fa8c..74707ff 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -472,6 +472,32 @@ ReachingDefAnalysis::isSafeToRemove(MachineInstr *MI, InstSet &Visited,
return true;
}
+void ReachingDefAnalysis::collectLocalKilledOperands(MachineInstr *MI,
+ InstSet &Dead) const {
+ Dead.insert(MI);
+ auto IsDead = [this](MachineInstr *Def, int PhysReg) {
+ unsigned LiveDefs = 0;
+ for (auto &MO : Def->defs())
+ if (!MO.isDead())
+ ++LiveDefs;
+
+ if (LiveDefs > 1)
+ return false;
+
+ SmallPtrSet<MachineInstr*, 4> Uses;
+ getGlobalUses(Def, PhysReg, Uses);
+ return Uses.size() == 1;
+ };
+
+ for (auto &MO : MI->uses()) {
+ if (!MO.isReg() || MO.getReg() == 0 || !MO.isKill())
+ continue;
+ if (MachineInstr *Def = getReachingMIDef(MI, MO.getReg()))
+ if (IsDead(Def, MO.getReg()))
+ collectLocalKilledOperands(Def, Dead);
+ }
+}
+
bool ReachingDefAnalysis::isSafeToDefRegAt(MachineInstr *MI,
int PhysReg) const {
SmallPtrSet<MachineInstr*, 1> Ignore;