Skip to content

Commit fc92e4d

Browse files
authored
[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.
1 parent 000e462 commit fc92e4d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ static bool PHIsEqualValue(PHINode *PN, Value *&NonPhiInVal,
10051005
return true;
10061006

10071007
// Don't scan crazily complex things.
1008-
if (ValueEqualPHIs.size() == 16)
1008+
if (ValueEqualPHIs.size() >= 16)
10091009
return false;
10101010

10111011
// Scan the operands to see if they are either phi nodes or are equal to

0 commit comments

Comments
 (0)