[all-commits] [llvm/llvm-project] b5d9a3: [Canonicalizer] Process regions top-down instead o...

Chris Lattner via All-commits all-commits at lists.llvm.org
Sun Mar 14 18:25:04 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b5d9a3c92358349d5444ab28de8ab5b2bee33a01
      https://github.com/llvm/llvm-project/commit/b5d9a3c92358349d5444ab28de8ab5b2bee33a01
  Author: Chris Lattner <clattner at nondot.org>
  Date:   2021-03-14 (Sun, 14 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Transforms/FoldUtils.h
    M mlir/lib/Transforms/Utils/FoldUtils.cpp
    M mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
    M mlir/test/Conversion/StandardToSPIRV/legalization.mlir
    M mlir/test/Conversion/VectorToSCF/vector-to-loops.mlir
    M mlir/test/Dialect/Affine/canonicalize.mlir
    M mlir/test/Dialect/Linalg/sparse_2d.mlir
    M mlir/test/Dialect/Linalg/transform-patterns.mlir
    M mlir/test/Dialect/Quant/convert-const.mlir
    M mlir/test/Dialect/SCF/canonicalize.mlir
    M mlir/test/Dialect/SPIRV/Transforms/canonicalize.mlir
    M mlir/test/Dialect/Tensor/canonicalize.mlir
    M mlir/test/Dialect/Vector/canonicalize.mlir
    M mlir/test/Dialect/Vector/vector-contract-transforms.mlir
    M mlir/test/Dialect/Vector/vector-flat-transforms.mlir
    M mlir/test/Dialect/Vector/vector-transfer-full-partial-split.mlir
    M mlir/test/Dialect/Vector/vector-transfer-unroll.mlir
    M mlir/test/Dialect/Vector/vector-transforms.mlir
    M mlir/test/Transforms/canonicalize.mlir
    M mlir/test/Transforms/parallel-loop-collapsing.mlir
    M mlir/test/Transforms/single-parallel-loop-collapsing.mlir
    M mlir/test/Transforms/test-canonicalize.mlir
    M mlir/test/mlir-tblgen/pattern.mlir

  Log Message:
  -----------
  [Canonicalizer] Process regions top-down instead of bottom up & reuse existing constants.

Two changes:
 1) Change the canonicalizer to walk the function in top-down order instead of
    bottom-up order.  This composes well with the "top down" nature of constant
    folding and simplification, reducing iterations and re-evaluation of ops in
    simple cases.
 2) Explicitly enter existing constants into the OperationFolder table before
    canonicalizing.  Previously we would "constant fold" them and rematerialize
    them, wastefully recreating a bunch fo constants, which lead to pointless
    memory traffic.

Both changes together provide a 33% speedup for canonicalize on some mid-size
CIRCT examples.

One artifact of this change is that the constants generated in normal pattern
application get inserted at the top of the function as the patterns are applied.
Because of this, we get "inverted" constants more often, which is an aethetic
change to the IR but does permute some testcases.

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




More information about the All-commits mailing list