[PATCH] D37163: [LICM] sink through non-trivially replicable PHI
Jun Bum Lim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 31 09:42:59 PDT 2017
junbuml marked 2 inline comments as done.
junbuml added a comment.
I agree that the test doesn't really require splitting since the operations of incoming values are the same (sub/mul) and all operands used in the sinkable chain (%N_addr.0.pn, %N, and %N2) dominate the PHI, so we can directly add PHIs for operands and share the same operation in the exit block like you comment. For me, it seems that the test case is a special case in which splitting is not required. In most case, I think splitting is required to sink through a non-trivially replicable PHI. For example, if operations of incoming values are different or any operands in the sinkable chain do not dominate the PHI, we should split preds.
For me, SimplifyCFG should clean up such foldable case. The test case seems to be handled properly by SimplifyCFG :
Out12:
%N_addr.0.pn.lcssa.sink = phi i32 [ %N_addr.0.pn, %Loop ], [ %N_addr.0.pn, %ContLoop ]
%N.sink = phi i32 [ %N, %Loop ], [ %N2, %ContLoop ]
%tmp.6.le = mul i32 %N, %N_addr.0.pn.lcssa.sink
%tmp.7.le = sub i32 %tmp.6.le, %N.sink
Would it make sense that LICM split preds for non-trivially replicable PHIs in general and let the SimplyCFG fold such case. If there is any case where SimplyCFG cannot fold, we can improve SimplyCFG.
https://reviews.llvm.org/D37163
More information about the llvm-commits
mailing list