summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-17 06:35:16 +0000
committerChris Lattner <sabre@nondot.org>2005-08-17 06:35:16 +0000
commit2bf7cb52130dda2ffaf683082b989c3d9e86163d (patch)
treef826a82cbfc5300c02cafd2018157f96cc95a181 /llvm/lib
parent79f8b62607795257dbdd6e063867390f970acb08 (diff)
downloadbcm5719-llvm-2bf7cb52130dda2ffaf683082b989c3d9e86163d.tar.gz
bcm5719-llvm-2bf7cb52130dda2ffaf683082b989c3d9e86163d.zip
Use a new helper to split critical edges, making the code simpler.
Do not claim to not change the CFG. We do change the cfg to split critical edges. This isn't causing us a problem now, but could likely do so in the future. llvm-svn: 22824
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index e97e0911c17..c8e86d8e9d5 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -119,7 +119,15 @@ namespace {
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesCFG();
+ // We split critical edges, so we change the CFG. However, we do update
+ // many analyses if they are around.
+ AU.addPreservedID(LoopSimplifyID);
+ AU.addPreserved<LoopInfo>();
+ AU.addPreserved<DominatorSet>();
+ AU.addPreserved<ImmediateDominators>();
+ AU.addPreserved<DominanceFrontier>();
+ AU.addPreserved<DominatorTree>();
+
AU.addRequiredID(LoopSimplifyID);
AU.addRequired<LoopInfo>();
AU.addRequired<DominatorSet>();
@@ -440,25 +448,20 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
// code on all predecessor/successor paths.
if (e != 1 &&
PN->getIncomingBlock(i)->getTerminator()->getNumSuccessors() > 1) {
- TerminatorInst *PredTI = PN->getIncomingBlock(i)->getTerminator();
- for (unsigned Succ = 0; ; ++Succ) {
- assert(Succ != PredTI->getNumSuccessors() &&"Didn't find successor?");
- if (PredTI->getSuccessor(Succ) == PN->getParent()) {
- // First step, split the critical edge.
- SplitCriticalEdge(PredTI, Succ, P);
+
+ // First step, split the critical edge.
+ SplitCriticalEdge(PN->getIncomingBlock(i), PN->getParent(), P);
- // Next step: move the basic block. In particular, if the PHI node
- // is outside of the loop, and PredTI is in the loop, we want to
- // move the block to be immediately before the PHI block, not
- // immediately after PredTI.
- if (L->contains(PredTI->getParent()) &&
- !L->contains(PN->getParent())) {
- BasicBlock *NewBB = PN->getIncomingBlock(i);
- NewBB->moveBefore(PN->getParent());
- }
- break;
- }
+ // Next step: move the basic block. In particular, if the PHI node
+ // is outside of the loop, and PredTI is in the loop, we want to
+ // move the block to be immediately before the PHI block, not
+ // immediately after PredTI.
+ if (L->contains(PN->getIncomingBlock(i)) &&
+ !L->contains(PN->getParent())) {
+ BasicBlock *NewBB = PN->getIncomingBlock(i);
+ NewBB->moveBefore(PN->getParent());
}
+ break;
}
Value *&Code = InsertedCode[PN->getIncomingBlock(i)];
OpenPOWER on IntegriCloud