diff options
author | Chris Lattner <sabre@nondot.org> | 2005-10-03 00:31:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-10-03 00:31:52 +0000 |
commit | 37edbf0b21959e176672ae51f8b7e86ba1ef727d (patch) | |
tree | 6d20f739e746e1f5ba4376ee2d782e37d9519498 /lib/Transforms | |
parent | 9390368970d14361a2ab8c2886e10cc51e42fd1a (diff) | |
download | external_llvm-37edbf0b21959e176672ae51f8b7e86ba1ef727d.zip external_llvm-37edbf0b21959e176672ae51f8b7e86ba1ef727d.tar.gz external_llvm-37edbf0b21959e176672ae51f8b7e86ba1ef727d.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23601 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 8293172..cf0b6b0 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/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()); } |