Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ bool InstCombinerImpl::foldDeadPhiWeb(PHINode &PN) {
SmallVector<PHINode *, 16> Stack;
SmallPtrSet<PHINode *, 16> Visited;
Stack.push_back(&PN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add the initial phi node to the Visited set.

Visited.insert(&PN);
while (!Stack.empty()) {
PHINode *Phi = Stack.pop_back_val();
if (!Visited.insert(Phi).second)
continue;
// Early stop if the set of PHIs is large
if (Visited.size() == 16)
return false;
for (User *Use : Phi->users()) {
if (PHINode *PhiUse = dyn_cast<PHINode>(Use))
if (PHINode *PhiUse = dyn_cast<PHINode>(Use)) {
if (!Visited.insert(PhiUse).second)
continue;
// Early stop if the set of PHIs is large
if (Visited.size() >= 16)
return false;
Stack.push_back(PhiUse);
else
} else
return false;
}
}
Expand Down