We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 95057f6 commit a3783a5Copy full SHA for a3783a5
llvm/lib/Transforms/Scalar/TailDuplication.cpp
@@ -157,8 +157,13 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
157
}
158
} else if (PHINode *PN = dyn_cast<PHINode>(cast<Instruction>(*UI))) {
159
// If the user of this instruction is a PHI node in the current block,
160
- // spill the value.
161
- ShouldDemote = true;
+ // which has an entry from another block using the value, spill it.
+ 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
+ }
167
168
169
if (ShouldDemote) {
0 commit comments