[LoopSink] Allow sinking to PHI-use
authorWenlei He <aktoon@gmail.com>
Tue, 13 Jun 2023 04:20:19 +0000 (21:20 -0700)
committerWenlei He <aktoon@gmail.com>
Tue, 13 Jun 2023 20:06:57 +0000 (13:06 -0700)
commit54711a6a5872d5f97da4c0a1bd7e58d0546ca701
tree8c705990a96a74489b9a0f0d8bb01ade45d57958
parenta9e1d2e760b502fb31ad522b0885a2150f008e86
[LoopSink] Allow sinking to PHI-use

This change allows sinking defs from loop preheader with PHI-use into loop body. Loop sink can now see through PHI-use and select incoming blocks of value being used as candidate sink destination.

It makes loop sink more effective so more LICM can be undone if proven unprofitable with profile info. It addresses the motivating case in D87551, without resorting to profile guided LICM which breaks canonicalization.

Differential Revision: https://reviews.llvm.org/D152772
llvm/lib/Transforms/Scalar/LoopSink.cpp
llvm/test/Transforms/LICM/loopsink-phi.ll [new file with mode: 0644]