[llvm] fc92e4d - [InstCombine] Fix bail-out in `PHIsEqualValue()` (#170650)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 7 17:11:33 PST 2025
Author: Mingjie Xu
Date: 2025-12-08T09:11:28+08:00
New Revision: fc92e4dec9a6dfcb4fb77d863d0bf1dbc53033e5
URL: https://github.com/llvm/llvm-project/commit/fc92e4dec9a6dfcb4fb77d863d0bf1dbc53033e5
DIFF: https://github.com/llvm/llvm-project/commit/fc92e4dec9a6dfcb4fb77d863d0bf1dbc53033e5.diff
LOG: [InstCombine] Fix bail-out in `PHIsEqualValue()` (#170650)
We encountered a such case: `PHIsEqualValue()` is called with a PHI node
`PN` whose incoming values are all PHI nodes, and `NonPhiInVal` is
nullptr. When the size of `ValueEqualPHIs` reaches 16, `NonPhiInVal` is
still nullptr, then we keep scanning PHI node operands, this time the
recursion won't bail out even if we have visited too many PHI nodes.
In our case, the recursion ends with ~1700 PHI nodes visited, causes
InstCombine time-consuming.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index de97b8e60ac65..ba1865a2b5469 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -1005,7 +1005,7 @@ static bool PHIsEqualValue(PHINode *PN, Value *&NonPhiInVal,
return true;
// Don't scan crazily complex things.
- if (ValueEqualPHIs.size() == 16)
+ if (ValueEqualPHIs.size() >= 16)
return false;
// Scan the operands to see if they are either phi nodes or are equal to
More information about the llvm-commits
mailing list