diff options
| author | Michael Kruse <llvm@meinersbur.de> | 2018-09-17 18:40:29 +0000 |
|---|---|---|
| committer | Michael Kruse <llvm@meinersbur.de> | 2018-09-17 18:40:29 +0000 |
| commit | 534c87df82909b63049b80d42b2390cd008c350a (patch) | |
| tree | 06c9ca2c6cde3c969243c8797c9bb78c1ff2c290 /llvm/lib | |
| parent | bd72988c3a583840bdc93cc796757a5a0a2e56fc (diff) | |
| download | bcm5719-llvm-534c87df82909b63049b80d42b2390cd008c350a.tar.gz bcm5719-llvm-534c87df82909b63049b80d42b2390cd008c350a.zip | |
[Loopinfo] Remove one latch-case in getLoopID. NFC.
getLoopID has different control flow for two cases: If there is a
single loop latch and for any other number of loop latches (0 and more
than one). The latter case should return the same result if there is
only a single latch. We can save the preceding redundant search for a
latch by handling both cases with the same code.
Differential Revision: https://reviews.llvm.org/D52118
llvm-svn: 342406
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 4664c78b8c0..07f72addc81 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -213,26 +213,21 @@ bool Loop::isSafeToClone() const { MDNode *Loop::getLoopID() const { MDNode *LoopID = nullptr; - if (BasicBlock *Latch = getLoopLatch()) { - LoopID = Latch->getTerminator()->getMetadata(LLVMContext::MD_loop); - } else { - assert(!getLoopLatch() && - "The loop should have no single latch at this point"); - // Go through the latch blocks and check the terminator for the metadata. - SmallVector<BasicBlock *, 4> LatchesBlocks; - getLoopLatches(LatchesBlocks); - for (BasicBlock *BB : LatchesBlocks) { - TerminatorInst *TI = BB->getTerminator(); - MDNode *MD = TI->getMetadata(LLVMContext::MD_loop); - - if (!MD) - return nullptr; - - if (!LoopID) - LoopID = MD; - else if (MD != LoopID) - return nullptr; - } + + // Go through the latch blocks and check the terminator for the metadata. + SmallVector<BasicBlock *, 4> LatchesBlocks; + getLoopLatches(LatchesBlocks); + for (BasicBlock *BB : LatchesBlocks) { + TerminatorInst *TI = BB->getTerminator(); + MDNode *MD = TI->getMetadata(LLVMContext::MD_loop); + + if (!MD) + return nullptr; + + if (!LoopID) + LoopID = MD; + else if (MD != LoopID) + return nullptr; } if (!LoopID || LoopID->getNumOperands() == 0 || LoopID->getOperand(0) != LoopID) |

