Skip to content

Commit 7ea0e5c

Browse files
Enna1Honey Goyal
authored andcommitted
[InstCombine] Fix bail-out in PHIsEqualValue() (llvm#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 6f20395 commit 7ea0e5c

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)