summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-03 00:31:52 +0000
committerChris Lattner <sabre@nondot.org>2005-10-03 00:31:52 +0000
commit8fcce170cf0d3c2a49b48f6dced0a4a63ce3f97c (patch)
tree25dc361096c368fc7705bbfabff653a5fbc26765 /llvm/lib/Transforms
parent77676d5bc20f67105bdcb4a3edae2b7a192d0040 (diff)
downloadbcm5719-llvm-8fcce170cf0d3c2a49b48f6dced0a4a63ce3f97c.tar.gz
bcm5719-llvm-8fcce170cf0d3c2a49b48f6dced0a4a63ce3f97c.zip
when checking if we should move a split edge block outside of a loop,
check the presplit pred, not the post-split pred. This was causing us to make the wrong decision in some cases, leaving the critical edge block in the loop. llvm-svn: 23601
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 82931726bce..cf0b6b0b958 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -462,20 +462,19 @@ void BasedUser::RewriteInstructionToUseNewBase(const SCEVHandle &NewBase,
// code on all predecessor/successor paths. We do this unless this is the
// canonical backedge for this loop, as this can make some inserted code
// be in an illegal position.
- if (e != 1 &&
- PN->getIncomingBlock(i)->getTerminator()->getNumSuccessors() > 1 &&
- (PN->getParent() != L->getHeader() ||
- !L->contains(PN->getIncomingBlock(i)))) {
+ BasicBlock *PHIPred = PN->getIncomingBlock(i);
+ if (e != 1 && PHIPred->getTerminator()->getNumSuccessors() > 1 &&
+ (PN->getParent() != L->getHeader() || !L->contains(PHIPred))) {
+
// First step, split the critical edge.
- SplitCriticalEdge(PN->getIncomingBlock(i), PN->getParent(), P);
+ SplitCriticalEdge(PHIPred, 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(PN->getIncomingBlock(i)) &&
- !L->contains(PN->getParent())) {
+ if (L->contains(PHIPred) && !L->contains(PN->getParent())) {
BasicBlock *NewBB = PN->getIncomingBlock(i);
NewBB->moveBefore(PN->getParent());
}
OpenPOWER on IntegriCloud