diff options
author | Clement Courbet <courbet@google.com> | 2018-02-06 12:25:33 +0000 |
---|---|---|
committer | Clement Courbet <courbet@google.com> | 2018-02-06 12:25:33 +0000 |
commit | a7a174686511dd7b3f3b7ca66983e644f52a4857 (patch) | |
tree | 43ddb5d9f19ca0411d746fccbe0e3dd0b49e7bc1 /llvm/lib/Transforms | |
parent | 9dc740d0a9ae2b14fbf897d021217b6b5ce54dcd (diff) | |
download | bcm5719-llvm-a7a174686511dd7b3f3b7ca66983e644f52a4857.tar.gz bcm5719-llvm-a7a174686511dd7b3f3b7ca66983e644f52a4857.zip |
[MergeICmps] Handle chains with several complex BCE basic blocks.
- Fix condition for detecting that a complex basic block was the first in
the chain.
- Add tests.
This was caught by buildbots when submitting rL324319.
llvm-svn: 324341
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/MergeICmps.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp index f045b62a922..745d29d14dd 100644 --- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp +++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp @@ -278,7 +278,8 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi) assert(!Blocks.empty() && "a chain should have at least one block"); // Now look inside blocks to check for BCE comparisons. std::vector<BCECmpBlock> Comparisons; - for (BasicBlock *Block : Blocks) { + for (size_t BlockIdx = 0; BlockIdx < Blocks.size(); ++BlockIdx) { + BasicBlock *const Block = Blocks[BlockIdx]; assert(Block && "invalid block"); BCECmpBlock Comparison = visitCmpBlock(Phi.getIncomingValueForBlock(Block), Block, Phi.getParent()); @@ -289,7 +290,7 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi) } if (Comparison.doesOtherWork()) { DEBUG(dbgs() << "block does extra work besides compare\n"); - if (Comparisons.empty()) { // First block. + if (BlockIdx == 0) { // First block. // TODO(courbet): The first block can do other things, and we should // split them apart in a separate block before the comparison chain. // Right now we just discard it and make the chain shorter. @@ -330,7 +331,7 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi) DEBUG(dbgs() << "\n"); Comparisons.push_back(Comparison); } - assert(!Comparisons.empty() && "chain with a single complex basic block"); + assert(!Comparisons.empty() && "chain with no BCE basic blocks"); EntryBlock_ = Comparisons[0].BB; Comparisons_ = std::move(Comparisons); #ifdef MERGEICMPS_DOT_ON |