[all-commits] [llvm/llvm-project] 3d8f84: [LICM] Make promotion faster

Nikita Popov via All-commits all-commits at lists.llvm.org
Tue Mar 2 13:21:58 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3d8f842712d49b0767832b6e3f65df2d3f19af4e
      https://github.com/llvm/llvm-project/commit/3d8f842712d49b0767832b6e3f65df2d3f19af4e
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-03-02 (Tue, 02 Mar 2021)

  Changed paths:
    M llvm/include/llvm/Analysis/AliasSetTracker.h
    M llvm/lib/Analysis/AliasSetTracker.cpp
    M llvm/lib/Transforms/Scalar/LICM.cpp

  Log Message:
  -----------
  [LICM] Make promotion faster

Even when MemorySSA-based LICM is used, an AST is still populated
for scalar promotion. As the AST has quadratic complexity, a lot
of time is spent in this step despite the existing access count
limit. This patch optimizes the identification of promotable stores.

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 is much faster in practice, because we need to perform AA
queries for O(NumPromotable^2 + NumPromotable*NumNonPromotable)
instead of O(NumTotal^2), and NumPromotable tends to be small.
Additionally, promotable accesses have loop invariant pointers,
for which AA is cheaper.

This has a signicant positive compile-time impact. We save ~1.8%
geomean on CTMark at O3, with 6% on lencod in particular and 25%
on individual files.

Conceptually, this change is NFC, but may not be so in practice,
because the AST is only an approximation, and can produce
different results depending on the order in which accesses are
added. However, there is at least no impact on the number of promotions
(licm.NumPromoted) in test-suite O3 configuration with this change.

Differential Revision: https://reviews.llvm.org/D89264




More information about the All-commits mailing list