[LICM] Compute a must execute property for the prefix of the header as we go
authorPhilip Reames <listmail@philipreames.com>
Fri, 4 May 2018 21:35:00 +0000 (21:35 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 4 May 2018 21:35:00 +0000 (21:35 +0000)
commit5b39acd111e082e2ba91eb83de7ecb9763f76115
tree523b7404a40150c719aabf6d6154fdeb9a903efb
parenta2e053638bbfea50b29a29ee687f1bdd6abd427f
[LICM] Compute a must execute property for the prefix of the header as we go

Computing this property within the existing walk ensures that the cost is linear with the size of the block. If we did this from within isGuaranteedToExecute, it would be quadratic without some very fancy caching.

This allows us to reliably catch a hoistable instruction within a header which may throw at some point *after* our hoistable instruction. It doesn't do anything for non-header cases, but given how common single block loops are, this seems very worthwhile.

llvm-svn: 331557
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/test/Transforms/LICM/preheader-safe.ll