summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnswitch.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
index b530f7c5dbd..4aae2bfc89c 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -975,6 +975,10 @@ void LoopUnswitch::UnswitchTrivialCondition(Loop *L, Value *Cond, Constant *Val,
<< " blocks] in Function "
<< L->getHeader()->getParent()->getName()
<< " on cond: " << *Val << " == " << *Cond << "\n");
+ // We are going to make essential changes to CFG. This may invalidate cached
+ // information for L or one of its parent loops in SCEV.
+ if (auto *SEWP = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>())
+ SEWP->getSE().forgetTopmostLoop(L);
// First step, split the preheader, so that we know that there is a safe place
// to insert the conditional branch. We will change loopPreheader to have a
@@ -1201,8 +1205,10 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
<< " blocks] in Function " << F->getName() << " when '"
<< *Val << "' == " << *LIC << "\n");
+ // We are going to make essential changes to CFG. This may invalidate cached
+ // information for L or one of its parent loops in SCEV.
if (auto *SEWP = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>())
- SEWP->getSE().forgetLoop(L);
+ SEWP->getSE().forgetTopmostLoop(L);
LoopBlocks.clear();
NewBlocks.clear();
OpenPOWER on IntegriCloud