LSR: teach isSimplifiedLoopNest to handle PHI IVUsers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick
2012-03-20 21:24:44 +00:00
parent f9492288bb
commit a3b10b8359
2 changed files with 40 additions and 1 deletions

View File

@@ -148,7 +148,14 @@ bool IVUsers::AddUsersIfInteresting(Instruction *I,
// Only consider IVUsers that are dominated by simplified loop
// headers. Otherwise, SCEVExpander will crash.
if (!isSimplifiedLoopNest(User->getParent(), DT, LI, SimpleLoopNests))
BasicBlock *UseBB = User->getParent();
// A phi's use is live out of its predecessor block.
if (PHINode *PHI = dyn_cast<PHINode>(User)) {
unsigned OperandNo = UI.getOperandNo();
unsigned ValNo = PHINode::getIncomingValueNumForOperand(OperandNo);
UseBB = PHI->getIncomingBlock(ValNo);
}
if (!isSimplifiedLoopNest(UseBB, DT, LI, SimpleLoopNests))
return false;
// Descend recursively, but not into PHI nodes outside the current loop.