summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LCSSA.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-10-31 16:30:03 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-10-31 16:30:03 +0000
commitccd492c9d6f3cb20b9eb24dc0f102544b482019b (patch)
treeffdb92a7a0f5a2af204399392bd5629807b6a1d2 /lib/Transforms/Utils/LCSSA.cpp
parent4c1b4b1fe794437cbb245b11650d9e4001c9605e (diff)
downloadllvm-ccd492c9d6f3cb20b9eb24dc0f102544b482019b.tar.gz
llvm-ccd492c9d6f3cb20b9eb24dc0f102544b482019b.tar.bz2
llvm-ccd492c9d6f3cb20b9eb24dc0f102544b482019b.tar.xz
LCSSA: Try to recover compile time regressions due to SCEV updates.
- Use value handle tricks to communicate use replacements instead of forgetLoop, this is a lot faster. - Move the "big hammer" out of the main loop so it's not called for every instruction. This should recover most (if not all) compile time regressions introduced by this code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LCSSA.cpp')
-rw-r--r--lib/Transforms/Utils/LCSSA.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp
index 38c1495fac..5e05c83c35 100644
--- a/lib/Transforms/Utils/LCSSA.cpp
+++ b/lib/Transforms/Utils/LCSSA.cpp
@@ -160,6 +160,12 @@ bool LCSSA::runOnLoop(Loop *TheLoop, LPPassManager &LPM) {
MadeChange |= ProcessInstruction(I, ExitBlocks);
}
}
+
+ // If we modified the code, remove any caches about the loop from SCEV to
+ // avoid dangling entries.
+ // FIXME: This is a big hammer, can we clear the cache more selectively?
+ if (SE && MadeChange)
+ SE->forgetLoop(L);
assert(L->isLCSSAForm(*DT));
PredCache.clear();
@@ -248,19 +254,8 @@ bool LCSSA::ProcessInstruction(Instruction *Inst,
// Remember that this phi makes the value alive in this block.
SSAUpdate.AddAvailableValue(ExitBB, PN);
-
- // If the exiting block is part of a loop inserting a PHI may change its
- // SCEV analysis. Conservatively drop any caches from it.
- if (SE)
- if (Loop *L = LI->getLoopFor(ExitBB))
- SE->forgetLoop(L);
}
- // If we added a PHI, drop the cache to avoid invalidating SCEV caches.
- // FIXME: This is a big hammer, can we clear the cache more selectively?
- if (SE && !AddedPHIs.empty())
- SE->forgetLoop(L);
-
// Rewrite all uses outside the loop in terms of the new PHIs we just
// inserted.
for (unsigned i = 0, e = UsesToRewrite.size(); i != e; ++i) {
@@ -273,12 +268,11 @@ bool LCSSA::ProcessInstruction(Instruction *Inst,
if (PHINode *PN = dyn_cast<PHINode>(User))
UserBB = PN->getIncomingBlock(*UsesToRewrite[i]);
- // Tell SCEV to reanalyze the value that's about to change.
- if (SE)
- SE->forgetValue(*UsesToRewrite[i]);
-
if (isa<PHINode>(UserBB->begin()) &&
isExitBlock(UserBB, ExitBlocks)) {
+ // Tell the VHs that the uses changed. This updates SCEV's caches.
+ if (UsesToRewrite[i]->get()->hasValueHandle())
+ ValueHandleBase::ValueIsRAUWd(*UsesToRewrite[i], UserBB->begin());
UsesToRewrite[i]->set(UserBB->begin());
continue;
}