[llvm] r272236 - Factor out a loopHasNoAbnormalExits; NFC
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 8 18:13:54 PDT 2016
Author: sanjoy
Date: Wed Jun 8 20:13:54 2016
New Revision: 272236
URL: http://llvm.org/viewvc/llvm-project?rev=272236&view=rev
Log:
Factor out a loopHasNoAbnormalExits; NFC
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=272236&r1=272235&r2=272236&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Wed Jun 8 20:13:54 2016
@@ -781,13 +781,15 @@ namespace llvm {
SmallVector<PointerIntPair<const Loop *, 2, LoopDisposition>, 2>>
LoopDispositions;
- /// A cache of the predicate "does the given loop contain an instruction
- /// that can abnormally exit the loop (i.e. via throwing an exception, by
- /// terminating the thread cleanly or by infinite looping in a called
- /// function)?" The last one is strictly not leaving the loop, but is
- /// identical to leaving the loop from the viewpoint of reasoning about
- /// undefined behavior.
- DenseMap<const Loop *, bool> LoopHasAbnormalExit;
+ /// Cache for \c loopHasNoAbnormalExits.
+ DenseMap<const Loop *, bool> LoopHasNoAbnormalExits;
+
+ /// Returns true if \p L contains no instruction that can abnormally exit
+ /// the loop (i.e. via throwing an exception, by terminating the thread
+ /// cleanly or by infinite looping in a called function). Strictly
+ /// speaking, the last one is not leaving the loop, but is identical to
+ /// leaving the loop for reasoning about undefined behavior.
+ bool loopHasNoAbnormalExits(const Loop *L);
/// Compute a LoopDisposition value.
LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=272236&r1=272235&r2=272236&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Jun 8 20:13:54 2016
@@ -4906,13 +4906,12 @@ bool ScalarEvolution::isAddRecNeverPoiso
}
}
- if (!LatchControlDependentOnPoison)
- return false;
-
- // Now check if loop has abonormal exits (or not), and cache the information.
+ return LatchControlDependentOnPoison && loopHasNoAbnormalExits(L);
+}
- auto Itr = LoopHasAbnormalExit.find(L);
- if (Itr == LoopHasAbnormalExit.end()) {
+bool ScalarEvolution::loopHasNoAbnormalExits(const Loop *L) {
+ auto Itr = LoopHasNoAbnormalExits.find(L);
+ if (Itr == LoopHasNoAbnormalExits.end()) {
bool HasAbnormalExit = false;
for (auto *BB : L->getBlocks()) {
HasAbnormalExit = any_of(*BB, [](Instruction &I) {
@@ -4921,12 +4920,12 @@ bool ScalarEvolution::isAddRecNeverPoiso
if (HasAbnormalExit)
break;
}
- auto InsertPair = LoopHasAbnormalExit.insert({L, HasAbnormalExit});
+ auto InsertPair = LoopHasNoAbnormalExits.insert({L, !HasAbnormalExit});
assert(InsertPair.second && "We just checked!");
Itr = InsertPair.first;
}
- return !Itr->second;
+ return Itr->second;
}
const SCEV *ScalarEvolution::createSCEV(Value *V) {
@@ -5490,7 +5489,7 @@ void ScalarEvolution::forgetLoop(const L
for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I)
forgetLoop(*I);
- LoopHasAbnormalExit.erase(L);
+ LoopHasNoAbnormalExits.erase(L);
}
void ScalarEvolution::forgetValue(Value *V) {
More information about the llvm-commits
mailing list