[LoopSink] Allow sinking to PHI-use (2nd attempt)
authorWenlei He <aktoon@gmail.com>
Fri, 23 Jun 2023 16:30:06 +0000 (09:30 -0700)
committerWenlei He <aktoon@gmail.com>
Fri, 23 Jun 2023 16:52:03 +0000 (09:52 -0700)
commit9a868a902c2d9aec295612132445efd220c52e86
treedebb7a2bc38e8d21aa4b0d0a44f89feb9cb0e0c5
parent8015ea6a6dd960494be8e0cbca33bf7783ca8af4
[LoopSink] Allow sinking to PHI-use (2nd attempt)

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.

This is the 2nd attempt after D152772.
llvm/lib/Transforms/Scalar/LoopSink.cpp
llvm/test/Transforms/LICM/loopsink-phi.ll [new file with mode: 0644]
llvm/test/Transforms/LICM/loopsink-phi2.ll [new file with mode: 0644]