diff options
author | Sam Parker <sam.parker@arm.com> | 2020-09-16 12:42:58 +0100 |
---|---|---|
committer | Sam Parker <sam.parker@arm.com> | 2020-09-16 12:44:23 +0100 |
commit | 1c421046d742102e7016567d41a9db6a1fb61906 (patch) | |
tree | 6bf3695be606a60eb68a40370850065b4fbf50b5 /llvm/lib/CodeGen/ReachingDefAnalysis.cpp | |
parent | 0a0abc0ede0ff8015e30aae89a3f89c7dc5b3f0f (diff) | |
download | llvm-1c421046d742102e7016567d41a9db6a1fb61906.zip llvm-1c421046d742102e7016567d41a9db6a1fb61906.tar.gz llvm-1c421046d742102e7016567d41a9db6a1fb61906.tar.bz2 |
[RDA] Fix getUniqueReachingDef for self loops
We've fixed the case where this could return an instruction after the
given instruction, but also means that we can falsely return a
'unique' def when they could be one coming from the backedge of a
loop.
Differential Revision: https://reviews.llvm.org/D87751
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 5a48370..86c2f63 100644 --- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp +++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp @@ -397,7 +397,6 @@ ReachingDefAnalysis::getGlobalReachingDefs(MachineInstr *MI, int PhysReg, return; } - SmallPtrSet<MachineBasicBlock *, 2> Visited; for (auto *MBB : MI->getParent()->predecessors()) getLiveOuts(MBB, PhysReg, Defs); } @@ -437,18 +436,15 @@ MachineInstr *ReachingDefAnalysis::getUniqueReachingMIDef(MachineInstr *MI, SmallPtrSet<MachineBasicBlock*, 4> VisitedBBs; SmallPtrSet<MachineInstr*, 2> Incoming; MachineBasicBlock *Parent = MI->getParent(); - VisitedBBs.insert(Parent); for (auto *Pred : Parent->predecessors()) - getLiveOuts(Pred, PhysReg, Incoming, VisitedBBs); + getLiveOuts(Pred, PhysReg, Incoming); - // If we have a local def and an incoming instruction, then there's not a - // unique instruction def. - if (!Incoming.empty() && LocalDef) - return nullptr; - else if (Incoming.size() == 1) + // Check that we have a single incoming value and that it does not + // come from the same block as MI - since it would mean that the def + // is executed after MI. + if (Incoming.size() == 1 && (*Incoming.begin())->getParent() != Parent) return *Incoming.begin(); - else - return LocalDef; + return nullptr; } MachineInstr *ReachingDefAnalysis::getMIOperand(MachineInstr *MI, |