LICM assumes that the sub loops cannot be modified by other loop passes (See the deleted comment starting with "What if"). It is true for the current loop optimization pipeline. However, if the pipeline is changed, the assumption may not be true (e.g. test/Transforms/LICM/AliasSetMemSet.ll which is discussed in this thread).
This patch first tests if there are more than one loop passes run together. If it is true, it calculates the AST from the scratch without using the LoopToAliasSetMap cache. This patch has no impact on either function or compilation time for the current loop optimization pipeline.