As mentioned at the MSSA roundtable, LICM spends a lot of time construction an AST, despite the caps already in place. This patch is a proposal on how to reduce the impact.
The idea here is pretty simple: We're only interested in must-alias mod sets of loop invariant pointers. As such, only populate the AST with loop-invariant loads and stores (anything else is definitely not promotable) and then discard any sets which alias with any of the remaining, definitely non-promotable accesses.
If we promoted something, check whether this has made some other accesses loop invariant and thus possible promotion candidates.
This has a large positive compile-time impact: https://llvm-compile-time-tracker.com/compare.php?from=f197cf2126be3b224cadfe8b1cde9c05f638a0ea&to=7f1e24e26d198e1d80d32c87c9fd1f5cf3cc8c5f&stat=instructions We save ~1.8% geomean at O3, and lencod in particular saves 6%, with up to 25% on individual files.
There is no impact on the number of promotions (licm.NumPromoted) in test-suite in the O3 configuration with this change.
Nit: It seems the conditions in IsPotentiallyPromotable would be useful as an early filter to prevent filling up the MaybePromotable only to clean it up shortly after.