diff options
author | Fedor Sergeev <fedor.sergeev@azul.com> | 2020-01-16 00:57:34 +0300 |
---|---|---|
committer | Fedor Sergeev <fedor.sergeev@azul.com> | 2020-01-16 01:15:57 +0300 |
commit | 8a4d12ae5b3e6b2ef7c851c6865c04d5a84e05f1 (patch) | |
tree | 13e72f9d81c3f09cee7d7d82ff5fa044410c6e48 /llvm/lib/Transforms/Scalar/LoopPredication.cpp | |
parent | 288a1436392f1fbee2e647cb057086fe700f9c7e (diff) | |
download | llvm-8a4d12ae5b3e6b2ef7c851c6865c04d5a84e05f1.zip llvm-8a4d12ae5b3e6b2ef7c851c6865c04d5a84e05f1.tar.gz llvm-8a4d12ae5b3e6b2ef7c851c6865c04d5a84e05f1.tar.bz2 |
[BasicBlock] add helper getPostdominatingDeoptimizeCall
It appears to be rather useful when analyzing Loops with multiple
deoptimizing exits, perhaps merged ones.
For now it is used in LoopPredication, will be adding more uses
in other loop passes.
Reviewers: asbirlea, fhahn, skatkov, spatel, reames
Reviewed By: reames
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D72754
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopPredication.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopPredication.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp index 1a42f6b..b96352d 100644 --- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp @@ -1020,17 +1020,6 @@ static const SCEV *getMinAnalyzeableBackedgeTakenCount(ScalarEvolution &SE, return SE.getUMinFromMismatchedTypes(ExitCounts); } -/// Return true if we can be fairly sure that executing block BB will probably -/// lead to executing an __llvm_deoptimize. This is a profitability heuristic, -/// not a legality constraint. -static bool isVeryLikelyToDeopt(BasicBlock *BB) { - while (BB->getUniqueSuccessor()) - // Will skip side effects, that's okay - BB = BB->getUniqueSuccessor(); - - return BB->getTerminatingDeoptimizeCall(); -} - /// This implements an analogous, but entirely distinct transform from the main /// loop predication transform. This one is phrased in terms of using a /// widenable branch *outside* the loop to allow us to simplify loop exits in a @@ -1150,10 +1139,13 @@ bool LoopPredication::predicateLoopExits(Loop *L, SCEVExpander &Rewriter) { const bool ExitIfTrue = !L->contains(*succ_begin(ExitingBB)); BasicBlock *ExitBB = BI->getSuccessor(ExitIfTrue ? 0 : 1); - if (!isVeryLikelyToDeopt(ExitBB)) - // Profitability: indicator of rarely/never taken exit + if (!ExitBB->getPostdominatingDeoptimizeCall()) continue; + /// Here we can be fairly sure that executing this exit will most likely + /// lead to executing llvm.experimental.deoptimize. + /// This is a profitability heuristic, not a legality constraint. + // If we found a widenable exit condition, do two things: // 1) fold the widened exit test into the widenable condition // 2) fold the branch to untaken - avoids infinite looping |