[llvm] [InstCombine] Improve `foldDeadPhiWeb` compile time (PR #158057)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 11 06:44:53 PDT 2025


================
@@ -62,15 +62,15 @@ bool InstCombinerImpl::foldDeadPhiWeb(PHINode &PN) {
   Stack.push_back(&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(Phi).second)
----------------
nikic wrote:

This should insert PhiUse, not Phi.

https://github.com/llvm/llvm-project/pull/158057


More information about the llvm-commits mailing list