diff options
| author | Xin Tong <trent.xin.tong@gmail.com> | 2018-03-20 11:57:54 +0000 |
|---|---|---|
| committer | Xin Tong <trent.xin.tong@gmail.com> | 2018-03-20 11:57:54 +0000 |
| commit | bdbd97ed9a70945669e7ad050d4b459160ae66c6 (patch) | |
| tree | 8cf7befb73df6d8c8330c607eb810e477f81cd19 /llvm/lib/Transforms | |
| parent | 16064d354afba2cbfd8826c96e8f3b575977df9d (diff) | |
| download | bcm5719-llvm-bdbd97ed9a70945669e7ad050d4b459160ae66c6.tar.gz bcm5719-llvm-bdbd97ed9a70945669e7ad050d4b459160ae66c6.zip | |
[MergeICmp] Fix a bug in entry block shuffled to middle of the chain
Summary: Fix a bug in entry block shuffled to middle of the chain.
Reviewers: davide, courbet
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D44642
llvm-svn: 327971
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/MergeICmps.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp index 5b82c320e7c..9ccba2dd18c 100644 --- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp +++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp @@ -403,6 +403,17 @@ bool BCECmpChain::simplify(const TargetLibraryInfo *const TLI) { Phi_.removeIncomingValue(Comparison.BB, false); } + // If entry block is part of the chain, we need to make the first block + // of the chain the new entry block of the function. + BasicBlock *Entry = &Comparisons_[0].BB->getParent()->getEntryBlock(); + for (size_t I = 1; I < Comparisons_.size(); ++I) { + if (Entry == Comparisons_[I].BB) { + BasicBlock *NEntryBB = BasicBlock::Create(Entry->getContext(), "", + Entry->getParent(), Entry); + BranchInst::Create(Entry, NEntryBB); + } + } + // Point the predecessors of the chain to the first comparison block (which is // the new entry point). if (EntryBlock_ != Comparisons_[0].BB) |

