diff options
author | Jatin Bhateja <jatin.bhateja@gmail.com> | 2017-11-26 15:08:41 +0000 |
---|---|---|
committer | Jatin Bhateja <jatin.bhateja@gmail.com> | 2017-11-26 15:08:41 +0000 |
commit | 081379e8b44c7e092517c11e23dc9fcc60542c32 (patch) | |
tree | 97b0e7ae60b347eca2cf992c32ce558c60eafbaa /lib/Analysis | |
parent | 40090f420c5f77f0bdfafbab4596a1605b767f4b (diff) |
[SCEV] Adding a check on outgoing branches of a terminator instr for SCEVBackedgeConditionFolder, NFC.
Summary:
For a given loop, getLoopLatch returns a non-null value
when a loop has only one latch block. In the modified
context adding an assertion to check that both the outgoing branches of
a terminator instruction (of latch) does not target same header.
+
few minor code reorganization.
Reviewers: jbhateja
Reviewed By: jbhateja
Subscribers: sanjoy
Differential Revision: https://reviews.llvm.org/D40460
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 53e216a5dc5..faf99c0a3c9 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -4049,9 +4049,6 @@ namespace { class SCEVInitRewriter : public SCEVRewriteVisitor<SCEVInitRewriter> { public: - SCEVInitRewriter(const Loop *L, ScalarEvolution &SE) - : SCEVRewriteVisitor(SE), L(L) {} - static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE) { SCEVInitRewriter Rewriter(L, SE); @@ -4076,6 +4073,9 @@ public: bool isValid() { return Valid; } private: + explicit SCEVInitRewriter(const Loop *L, ScalarEvolution &SE) + : SCEVRewriteVisitor(SE), L(L) {} + const Loop *L; bool Valid = true; }; @@ -4093,6 +4093,8 @@ public: if (BasicBlock *Latch = L->getLoopLatch()) { BranchInst *BI = dyn_cast<BranchInst>(Latch->getTerminator()); if (BI && BI->isConditional()) { + assert(BI->getSuccessor(0) != BI->getSuccessor(1) && + "Both outgoing branches should not target same header!"); BECond = BI->getCondition(); IsPosBECond = BI->getSuccessor(0) == L->getHeader(); } else { @@ -4160,9 +4162,6 @@ SCEVBackedgeConditionFolder::compareWithBackedgeCondition(Value *IC) { class SCEVShiftRewriter : public SCEVRewriteVisitor<SCEVShiftRewriter> { public: - SCEVShiftRewriter(const Loop *L, ScalarEvolution &SE) - : SCEVRewriteVisitor(SE), L(L) {} - static const SCEV *rewrite(const SCEV *S, const Loop *L, ScalarEvolution &SE) { SCEVShiftRewriter Rewriter(L, SE); @@ -4187,6 +4186,9 @@ public: bool isValid() { return Valid; } private: + explicit SCEVShiftRewriter(const Loop *L, ScalarEvolution &SE) + : SCEVRewriteVisitor(SE), L(L) {} + const Loop *L; bool Valid = true; }; @@ -11342,10 +11344,6 @@ namespace { class SCEVPredicateRewriter : public SCEVRewriteVisitor<SCEVPredicateRewriter> { public: - SCEVPredicateRewriter(const Loop *L, ScalarEvolution &SE, - SmallPtrSetImpl<const SCEVPredicate *> *NewPreds, - SCEVUnionPredicate *Pred) - : SCEVRewriteVisitor(SE), NewPreds(NewPreds), Pred(Pred), L(L) {} /// Rewrites \p S in the context of a loop L and the SCEV predication /// infrastructure. @@ -11406,6 +11404,11 @@ public: } private: + explicit SCEVPredicateRewriter(const Loop *L, ScalarEvolution &SE, + SmallPtrSetImpl<const SCEVPredicate *> *NewPreds, + SCEVUnionPredicate *Pred) + : SCEVRewriteVisitor(SE), NewPreds(NewPreds), Pred(Pred), L(L) {} + bool addOverflowAssumption(const SCEVPredicate *P) { if (!NewPreds) { // Check if we've already made this assumption. |