Skip to content

Commit a3783a5

Browse files
committed
Fix bug in previous checkin
llvm-svn: 12458
1 parent 95057f6 commit a3783a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/Transforms/Scalar/TailDuplication.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,13 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
157157
}
158158
} else if (PHINode *PN = dyn_cast<PHINode>(cast<Instruction>(*UI))) {
159159
// If the user of this instruction is a PHI node in the current block,
160-
// spill the value.
161-
ShouldDemote = true;
160+
// which has an entry from another block using the value, spill it.
161+
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
162+
if (PN->getIncomingValue(i) == I &&
163+
PN->getIncomingBlock(i) != DestBlock) {
164+
ShouldDemote = true;
165+
break;
166+
}
162167
}
163168

164169
if (ShouldDemote) {

0 commit comments

Comments
 (0)