[mlir] Create a generic reduction detection utility
authorDiego Caballero <diegocaballero@google.com>
Wed, 22 Sep 2021 17:11:45 +0000 (17:11 +0000)
committerDiego Caballero <diegocaballero@google.com>
Fri, 24 Sep 2021 20:45:59 +0000 (20:45 +0000)
commit2a876a711dc7c644936017daf20e78f48bfd2270
tree93801070edbe266df5c33cb74a16f1f684a51bb7
parenta7cdcf25c17e169eedba276791299c3b2b78fbf1
[mlir] Create a generic reduction detection utility

This patch introduces a generic reduction detection utility that works
across different dialecs. It is mostly a generalization of the reduction
detection algorithm in Affine. The reduction detection logic in Affine,
Linalg and SCFToOpenMP have been replaced with this new generic utility.

The utility takes some basic components of the potential reduction and
returns: 1) the reduced value, and 2) a list with the combiner operations.
The logic to match reductions involving multiple combiner operations disabled
until we can properly test it.

Reviewed By: ftynse, bondhugula, nicolasvasilache, pifon2a

Differential Revision: https://reviews.llvm.org/D110303
14 files changed:
mlir/include/mlir/Analysis/LoopAnalysis.h
mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
mlir/include/mlir/IR/Diagnostics.h
mlir/lib/Analysis/AffineAnalysis.cpp
mlir/lib/Analysis/LoopAnalysis.cpp
mlir/lib/Conversion/SCFToOpenMP/CMakeLists.txt
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/lib/IR/Diagnostics.cpp
mlir/test/Analysis/test-match-reduction.mlir [new file with mode: 0644]
mlir/test/lib/Analysis/CMakeLists.txt
mlir/test/lib/Analysis/TestMatchReduction.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/mlir-opt.cpp
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel