diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopPeel.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopPeel.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopPeel.cpp b/llvm/lib/Transforms/Utils/LoopPeel.cpp index 52ce7af..f348d24 100644 --- a/llvm/lib/Transforms/Utils/LoopPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopPeel.cpp @@ -330,10 +330,6 @@ static unsigned peelToTurnInvariantLoadsDerefencebale(Loop &L, bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) { const SCEV *BTC = SE.getBackedgeTakenCount(&L); - Value *Inc; - CmpPredicate Pred; - BasicBlock *Succ1; - BasicBlock *Succ2; // The loop must execute at least 2 iterations to guarantee that peeled // iteration executes. // TODO: Add checks during codegen. @@ -347,12 +343,18 @@ bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) { // * the exit condition must be a NE/EQ compare of an induction with step // of 1 and must only be used by the exiting branch. BasicBlock *Latch = L.getLoopLatch(); + Value *Inc; + Value *Bound; + CmpPredicate Pred; + BasicBlock *Succ1; + BasicBlock *Succ2; return Latch && Latch == L.getExitingBlock() && match(Latch->getTerminator(), - m_Br(m_OneUse(m_ICmp(Pred, m_Value(Inc), m_Value())), + m_Br(m_OneUse(m_ICmp(Pred, m_Value(Inc), m_Value(Bound))), m_BasicBlock(Succ1), m_BasicBlock(Succ2))) && ((Pred == CmpInst::ICMP_EQ && Succ2 == L.getHeader()) || (Pred == CmpInst::ICMP_NE && Succ1 == L.getHeader())) && + SE.isLoopInvariant(SE.getSCEV(Bound), &L) && match(SE.getSCEV(Inc), m_scev_AffineAddRec(m_SCEV(), m_scev_One(), m_SpecificLoop(&L))); } |