diff options
| author | Serguei Katkov <serguei.katkov@azul.com> | 2018-05-18 04:56:28 +0000 |
|---|---|---|
| committer | Serguei Katkov <serguei.katkov@azul.com> | 2018-05-18 04:56:28 +0000 |
| commit | 5095883fe9323384d202064aafdfadf57405bfc0 (patch) | |
| tree | 560c81fedd5e8280788f359362ed926b07c3cfde /llvm/lib/Analysis | |
| parent | 1e11fc1ccb399b9913f89e6253102ba1372ea97e (diff) | |
| download | bcm5719-llvm-5095883fe9323384d202064aafdfadf57405bfc0.tar.gz bcm5719-llvm-5095883fe9323384d202064aafdfadf57405bfc0.zip | |
[LICM] Extend the MustExecute scope
CanProveNotTakenFirstIteration utility does not handle the case when
condition of the branch is a constant. Add its handling.
Reviewers: reames, anna, mkazantsev
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D46996
llvm-svn: 332695
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/MustExecute.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp index d8bc7fa19ae..7b1bb2037f3 100644 --- a/llvm/lib/Analysis/MustExecute.cpp +++ b/llvm/lib/Analysis/MustExecute.cpp @@ -70,6 +70,10 @@ static bool CanProveNotTakenFirstIteration(BasicBlock *ExitBlock, auto *BI = dyn_cast<BranchInst>(CondExitBlock->getTerminator()); if (!BI || !BI->isConditional()) return false; + // If condition is constant and false leads to ExitBlock then we always + // execute the true branch. + if (auto *Cond = dyn_cast<ConstantInt>(BI->getCondition())) + return BI->getSuccessor(Cond->getZExtValue() ? 1 : 0) == ExitBlock; auto *Cond = dyn_cast<CmpInst>(BI->getCondition()); if (!Cond) return false; |

