1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00

Fix LICM/2003-12-11-SinkingToPHI.ll, and quite possibly all of the other known problems in the universe.

llvm-svn: 10409
This commit is contained in:
Chris Lattner 2003-12-11 22:23:32 +00:00
parent 5c22cf763f
commit 1f7737b44f

View File

@ -337,9 +337,18 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
/// exit blocks of the loop.
///
bool LICM::isNotUsedInLoop(Instruction &I) {
for (Value::use_iterator UI = I.use_begin(), E = I.use_end(); UI != E; ++UI)
if (CurLoop->contains(cast<Instruction>(*UI)->getParent()))
for (Value::use_iterator UI = I.use_begin(), E = I.use_end(); UI != E; ++UI) {
Instruction *User = cast<Instruction>(*UI);
if (PHINode *PN = dyn_cast<PHINode>(User)) {
// PHI node uses occur in predecessor blocks!
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
if (PN->getIncomingValue(i) == &I)
if (CurLoop->contains(PN->getIncomingBlock(i)))
return false;
} else if (CurLoop->contains(User->getParent())) {
return false;
}
}
return true;
}