In the combination of addressing modes, when replacing the matched phi nodes, sometimes the phi node to be replaced has been modified.
For example, there’s Matcher set [A, B] and [C, A], which will have cyclic dependency: A is replaced by B and C will be replaced by A . So we need to update the second phi node in matcher set when the phi node is already replaced.
Details
Diff Detail
Event Timeline
It seems that correct fix should be something different.
The underlying idea of implementation is as follows:
We built phi nodes to get, for example, base address in a point of usage. (in you example it is an offset).
Now we try to find whether there are already existing phi nodes which provide us with the base.
So we try to match all new phi nodes to already existed.
The bug you found actually happened due to we tried to match new phi node to another new phi node and at the end it results in the bug.
So I guess the better fix would be to just ignore new phi nodes when we try to map new phi node to old one.
llvm/lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
3731 | I guess the change of this comparison to if (PhiNodesToMatch.count(&P)) should fix your problem. |
llvm/lib/CodeGen/CodeGenPrepare.cpp | ||
---|---|---|
3731 | Please add a comment, like: |
I guess the change of this comparison to if (PhiNodesToMatch.count(&P)) should fix your problem.