[all-commits] [llvm/llvm-project] 412ae1: [Dominators] Rewrite the dominator implementation ...

Chris Lattner via All-commits all-commits at lists.llvm.org
Tue Jun 1 14:58:35 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 412ae15de49a227de25a695735451f8908ebf999
      https://github.com/llvm/llvm-project/commit/412ae15de49a227de25a695735451f8908ebf999
  Author: Chris Lattner <clattner at nondot.org>
  Date:   2021-06-01 (Tue, 01 Jun 2021)

  Changed paths:
    M mlir/include/mlir/IR/Dominance.h
    M mlir/include/mlir/IR/Region.h
    M mlir/lib/IR/Dominance.cpp
    M mlir/lib/IR/Region.cpp
    M mlir/lib/Transforms/BufferOptimizations.cpp
    M mlir/lib/Transforms/CSE.cpp

  Log Message:
  -----------
  [Dominators] Rewrite the dominator implementation for efficiency. NFC.

The previous impl densely scanned the entire region starting with an op
when dominators were created, creating a DominatorTree for every region.

This is extremely expensive up front -- particularly for clients like
Linalg/Transforms/Fusion.cpp that construct DominanceInfo for a single
query.  It is also extremely memory wasteful for IRs that use single
block regions commonly (e.g. affine.for) because it's making a
dominator tree for a region that has trivial dominance.  The
implementation also had numerous unnecessary minor efficiencies, e.g.
doing multiple walks of the region tree or tryGetBlocksInSameRegion
building a DenseMap that it didn't need.

This patch switches to an approach where [Post]DominanceInfo is free
to construct, and which lazily constructs DominatorTree's for any
multiblock regions that it needs.  This avoids the up-front cost
entirely, making its runtime proportional to the complexity of the
region tree instead of # ops in a region.  This also avoids the memory
and time cost of creating DominatorTree's for single block regions.

Finally this rewrites the implementation for simplicity and to avoids
the constant factor problems the old implementation had.

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




More information about the All-commits mailing list