diff options
author | Renato Golin <renato.golin@linaro.org> | 2015-08-13 11:25:38 +0000 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2015-08-13 11:25:38 +0000 |
commit | 655348f0b2d40a4644410b042a0c091bede910da (patch) | |
tree | b75e93bb0a2930952a9accec168ba5404aa1febc | |
parent | 4d57906b0e8a001dd0de52a3623d998b3b415a53 (diff) | |
download | bcm5719-llvm-655348f0b2d40a4644410b042a0c091bede910da.tar.gz bcm5719-llvm-655348f0b2d40a4644410b042a0c091bede910da.zip |
Revert "[LIR] Start leveraging the fundamental guarantees of a loop..."
This reverts commit r244879, as it broke the test-suite on
SingleSource/Regression/C/2004-03-15-IndirectGoto in AArch64.
llvm-svn: 244885
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index f2f37eec53b..e3fe2530c2b 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -830,32 +830,29 @@ bool LoopIdiomRecognize::recognizePopcount() { // non-compact loop. Therefore, recognizing popcount idiom only makes sense // in a compact loop. - assert(CurLoop->isLoopSimplifyForm() && - "Loop passes require simplified form!"); - - // Give up if the loop has multiple blocks. - if (CurLoop->getNumBlocks() != 1) + // Give up if the loop has multiple blocks or multiple backedges. + if (CurLoop->getNumBackEdges() != 1 || CurLoop->getNumBlocks() != 1) return false; - // If the loop is too big, bail out. - BasicBlock &LoopBB = *CurLoop->getHeader(); - if (LoopBB.size() >= 20) + BasicBlock *LoopBody = *(CurLoop->block_begin()); + if (LoopBody->size() >= 20) { + // The loop is too big, bail out. return false; + } // It should have a preheader containing nothing but an unconditional branch. - BasicBlock &PH = *CurLoop->getLoopPreheader(); - if (&PH.front() != PH.getTerminator()) + BasicBlock *PH = CurLoop->getLoopPreheader(); + if (!PH) + return false; + if (&PH->front() != PH->getTerminator()) return false; - // FIXME: Technically, it shouldn't matter what instruction we use as - // a terminator, the only property needed is the definition of a preheader: - // a single loop predecessor whose only successor is the loop header. - auto *EntryBI = dyn_cast<BranchInst>(PH.getTerminator()); + auto *EntryBI = dyn_cast<BranchInst>(PH->getTerminator()); if (!EntryBI || EntryBI->isConditional()) return false; // It should have a precondition block where the generated popcount instrinsic // function can be inserted. - auto *PreCondBB = PH.getSinglePredecessor(); + auto *PreCondBB = PH->getSinglePredecessor(); if (!PreCondBB) return false; auto *PreCondBI = dyn_cast<BranchInst>(PreCondBB->getTerminator()); |