[PATCH] D121381: [MemorySSA] Support lazy use optimization

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 13:56:18 PST 2022


nikic added a comment.

In D121381#3373615 <https://reviews.llvm.org/D121381#3373615>, @asbirlea wrote:

> Thank you for sending this out!
>
> Broadly the changes look good. The patch as is can also give some compile-time improvements for cases where MSSA is built and preserved in loop pipelines and need only be optimized before LICM, not before the first loop pass in the pipeline. This also means results may change based on the delayed optimization.
> This should hold true for both Legacy and NPM, but I see in practice there's a difference only for LPM (http://llvm-compile-time-tracker.com/compare.php?from=067c035012fc061ad6378458774ac2df117283c6&to=59191057243e34d85b644716ef2811bfea8efd1e&stat=instructions)

I think this is because with the LegacyPM, loop analyses (including MSSA) will get scheduled unconditionally, even if there are no loops, so we sometimes compute MSSA unnecessarily. With the NewPM, analyses are only computed if there are loops, so we generally don't perform unnecessary MSSA constructions there.

> Let me test this out as is first. Then separately with the EarlyCSE ensureOptimized() removed to check if the gains in compile-time are not coupled with run time regressions.

I should mention here that this does impact EarlyCSE results due to this fallback: https://github.com/llvm/llvm-project/blob/54d7fde46e8a0e425245e18732c2a78e64fa7b35/llvm/lib/Transforms/Scalar/EarlyCSE.cpp#L1030-L1034 Without eagerly optimizing uses, the `getDefiningAccess()` fallback will be unoptimized for uses. But I think we can compensate this by increasing the EarlyCSEMssaOptCap if necessary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121381/new/

https://reviews.llvm.org/D121381



More information about the llvm-commits mailing list