[PATCH] D46422: [LCSSA] Iteratively remove unused PHI nodes in formLCSSAForInstructions
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 4 15:46:35 PDT 2018
bjope added a comment.
With the new test case the method formLCSSAForInstructions is invoked three times (three loops?).
The third time the following PHI nodes are created (below is the order in which they are inserted in PHIsToRemoveIfNotUsed):
%value.lcssa = phi i16 [ %value.lcssa, %www ], [ %value, %gazank ]
%value.lcssa1 = phi i16 [ %value, %gazink ]
%value.lcssa2 = phi i16 [ %value3.lcssa, %exit1.pred ], [ %value, %gazonk ]
%value3.lcssa = phi i16 [ %value3, %foo ]
%value3.lcssa4 = phi i16 [ undef, %unreachable1 ], [ %value3, %bar ]
%value.lcssa.lcssa = phi i16 [ %value3.lcssa4, %exit2.pred ], [ %value.lcssa, %qqq ]
%value.lcssa.lcssa5 = phi i16 [ %value.lcssa, %www ]
`%value3.lcssa4` is for example used by a later created PHI node `%value.lcssa.lcssa = phi`.
The removal will be done in two iterations.
Iteration 1 removes:
%value.lcssa2 = phi i16 [ %value3.lcssa, %exit1.pred ], [ %value, %gazonk ]
%value3.lcssa = phi i16 [ %value3, %foo ]
%value.lcssa.lcssa = phi i16 [ %value3.lcssa4, %exit2.pred ], [ %value.lcssa, %qqq ]
So the remaining candidates for the second iteration are:
%value.lcssa = phi i16 [ %value.lcssa, %www ], [ %value, %gazank ]
%value.lcssa1 = phi i16 [ %value, %gazink ]
%value3.lcssa4 = phi i16 [ undef, %unreachable1 ], [ %value3, %bar ]
%value.lcssa.lcssa5 = phi i16 [ %value.lcssa, %www ]
Iteration 2 removes:
%value3.lcssa4 = phi i16 [ undef, %unreachable1 ], [ %value3, %bar ]
However, when examining that PHI node in the first iteration we could not remove it because we had not yet removed `%value.lcssa.lcssa = phi`.
The remaining PHI nodes that were created by formLCSSAForInstructions are used elsewhere, so they are not removed.
Repository:
rL LLVM
https://reviews.llvm.org/D46422
More information about the llvm-commits
mailing list