[all-commits] [llvm/llvm-project] f9be7a: [mlir] speed up construction of LLVM IR constants ...

ftynse via All-commits all-commits at lists.llvm.org
Thu Sep 2 14:07:45 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f9be7a7afda3c90b99c9f50e5eff1624da5a6511
      https://github.com/llvm/llvm-project/commit/f9be7a7afda3c90b99c9f50e5eff1624da5a6511
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2021-09-02 (Thu, 02 Sep 2021)

  Changed paths:
    M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    M mlir/test/Target/LLVMIR/llvmir.mlir

  Log Message:
  -----------
  [mlir] speed up construction of LLVM IR constants when possible

The translation to LLVM IR used to construct sequential constants by recurring
down to individual elements, creating constant values for them, and wrapping
them into aggregate constants in post-order. This is highly inefficient for
large constants with known data such as DenseElementsAttr. Use LLVM's
ConstantData for the innermost dimension instead. LLVM does seem to support
data constants for nested sequential constants so the outer dimensions are
still handled recursively. Nevertheless, this speeds up the translation of
large constants with equal dimensions by up to 30x.

Users are advised to rewrite large constants to use flat types before
translating to LLVM IR if more efficiency in translation is necessary. This is
not done automatically as the translation is not aware of the expectations of
the overall compilation flow about type changes and indexing, in particular for
global constants with external linkage.

Reviewed By: silvas

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




More information about the All-commits mailing list