[PATCH] D43997: [SCEV][NFC] Smarter implementation of isAvailableAtLoopEntry
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 13 00:48:41 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327373: [SCEV][NFC] Smarter implementation of isAvailableAtLoopEntry (authored by mkazantsev, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43997?vs=136681&id=138133#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43997
Files:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -2234,59 +2234,7 @@
}
bool ScalarEvolution::isAvailableAtLoopEntry(const SCEV *S, const Loop *L) {
- 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;
+ return isLoopInvariant(S, L) && properlyDominates(S, L->getHeader());
}
/// Get a canonical add expression, or something simpler if possible.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43997.138133.patch
Type: text/x-patch
Size: 2093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180313/96ed1895/attachment.bin>
More information about the llvm-commits
mailing list