diff options
author | Diana Picus <diana.picus@linaro.org> | 2017-05-24 14:16:04 +0000 |
---|---|---|
committer | Diana Picus <diana.picus@linaro.org> | 2017-05-24 14:16:04 +0000 |
commit | 183863fc3be326241178b189515e18e06dea5dce (patch) | |
tree | c36799b1f0b8112209a3b4c9393faf07e9527ebe /llvm/lib/Analysis | |
parent | e3ec97b031ff6ce9512e40e662ce6d26f393cb1f (diff) | |
download | bcm5719-llvm-183863fc3be326241178b189515e18e06dea5dce.tar.gz bcm5719-llvm-183863fc3be326241178b189515e18e06dea5dce.zip |
Revert "[SCEV] Do not fold dominated SCEVUnknown into AddRecExpr start"
This reverts commit r303730 because it broke all the buildbots.
llvm-svn: 303747
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 584419c1df3..78ded8141c0 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -2178,63 +2178,6 @@ StrengthenNoWrapFlags(ScalarEvolution *SE, SCEVTypes Type, return Flags; } -bool ScalarEvolution::isAvailableAtLoopEntry(const SCEV *S, const Loop *L, - DominatorTree &DT, LoopInfo &LI) { - if (!isLoopInvariant(S, L)) - return false; - // If a value depends on a SCEVUnknown which is defined after the loop, we - // conservatively assume that we cannot calculate it at the loop's entry. - struct FindDominatedSCEVUnknown { - bool Found = false; - const Loop *L; - DominatorTree &DT; - LoopInfo &LI; - - FindDominatedSCEVUnknown(const Loop *L, DominatorTree &DT, LoopInfo &LI) - : L(L), DT(DT), LI(LI) {} - - bool checkSCEVUnknown(const SCEVUnknown *SU) { - if (auto *I = dyn_cast<Instruction>(SU->getValue())) { - if (DT.dominates(L->getHeader(), I->getParent())) - Found = true; - else - assert(DT.dominates(I->getParent(), L->getHeader()) && - "No dominance relationship between SCEV and loop?"); - } - return false; - } - - bool follow(const SCEV *S) { - switch (static_cast<SCEVTypes>(S->getSCEVType())) { - case scConstant: - return false; - case scAddRecExpr: - case scTruncate: - case scZeroExtend: - case scSignExtend: - case scAddExpr: - case scMulExpr: - case scUMaxExpr: - case scSMaxExpr: - case scUDivExpr: - return true; - case scUnknown: - return checkSCEVUnknown(cast<SCEVUnknown>(S)); - case scCouldNotCompute: - llvm_unreachable("Attempt to use a SCEVCouldNotCompute object!"); - } - return false; - } - - bool isDone() { return Found; } - }; - - FindDominatedSCEVUnknown FSU(L, DT, LI); - SCEVTraversal<FindDominatedSCEVUnknown> ST(FSU); - ST.visitAll(S); - return !FSU.Found; -} - /// Get a canonical add expression, or something simpler if possible. const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops, SCEV::NoWrapFlags Flags, @@ -2516,7 +2459,7 @@ const SCEV *ScalarEvolution::getAddExpr(SmallVectorImpl<const SCEV *> &Ops, const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]); const Loop *AddRecLoop = AddRec->getLoop(); for (unsigned i = 0, e = Ops.size(); i != e; ++i) - if (isAvailableAtLoopEntry(Ops[i], AddRecLoop, DT, LI)) { + if (isLoopInvariant(Ops[i], AddRecLoop)) { LIOps.push_back(Ops[i]); Ops.erase(Ops.begin()+i); --i; --e; @@ -2791,7 +2734,7 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl<const SCEV *> &Ops, const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ops[Idx]); const Loop *AddRecLoop = AddRec->getLoop(); for (unsigned i = 0, e = Ops.size(); i != e; ++i) - if (isAvailableAtLoopEntry(Ops[i], AddRecLoop, DT, LI)) { + if (isLoopInvariant(Ops[i], AddRecLoop)) { LIOps.push_back(Ops[i]); Ops.erase(Ops.begin()+i); --i; --e; |