diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 28f88f39a712..a8445e94e55a 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -230,6 +230,27 @@ static Loop *separateNestedLoop(Loop *L, BasicBlock *Preheader, if (!Preheader) return nullptr; + // Treat the presence of convergent functions conservatively. The + // transformation is invalid if calls to certain convergent + // functions (like an AMDGPU barrier) get included in the resulting + // inner loop. But blocks meant for the inner loop will be + // identified later at a point where it's too late to abort the + // transformation. Also, the convergent attribute is not really + // sufficient to express the semantics of functions that are + // affected by this transformation. So we choose to back off if such + // a function call is present until a better alternative becomes + // available. This is similar to the conservative treatment of + // convergent function calls in GVNHoist and JumpThreading. + for (auto BB : L->blocks()) { + for (auto &II : *BB) { + if (auto CI = dyn_cast<CallBase>(&II)) { + if (CI->isConvergent()) { + return nullptr; + } + } + } + } + // The header is not a landing pad; preheader insertion should ensure this. BasicBlock *Header = L->getHeader(); assert(!Header->isEHPad() && "Can't insert backedge to EH pad"); @@ -598,6 +619,7 @@ ReprocessLoop: if (!PreserveLCSSA || LI->replacementPreservesLCSSAForm(PN, V)) { PN->replaceAllUsesWith(V); PN->eraseFromParent(); + Changed = true; } } @@ -674,10 +696,8 @@ ReprocessLoop: LI->removeBlock(ExitingBlock); DomTreeNode *Node = DT->getNode(ExitingBlock); - const std::vector<DomTreeNodeBase<BasicBlock> *> &Children = - Node->getChildren(); - while (!Children.empty()) { - DomTreeNode *Child = Children.front(); + while (!Node->isLeaf()) { + DomTreeNode *Child = Node->back(); DT->changeImmediateDominator(Child, Node->getIDom()); } DT->eraseNode(ExitingBlock); |