[mlir][Affine] Add helper functions to allow reordering affine.apply operands and...
authorNicolas Vasilache <nicolas.vasilache@gmail.com>
Mon, 13 Mar 2023 19:29:10 +0000 (12:29 -0700)
committerNicolas Vasilache <nicolas.vasilache@gmail.com>
Tue, 14 Mar 2023 11:07:32 +0000 (04:07 -0700)
commit0fa20ecafe0c3c7ffde413800eb4b1551b432273
treed39618da5e17d44d105e2a4d486edc00037a98d8
parent5b86eaeb7e4d0b508e8dc9592b63361c5abb1e48
[mlir][Affine] Add helper functions to allow reordering affine.apply operands and decompose the ops into smaller components

Care is taken to order operands from least hoistable to most hoistable and to process subexpressions in the same
order.

This allows exposing more oppportunities for licm, cse and strength reduction.

Such a step should typically be applied while we still have loops in the IR and just before lowering affine ops to arith.
This is because the affine.apply canonicalization currently tries to maximally compose chains of affine.apply operations
and could undo the effects of these decompositions.

Depends on: D145784

Differential Revision: https://reviews.llvm.org/D145685
mlir/include/mlir/Dialect/Affine/Passes.h
mlir/include/mlir/Dialect/Affine/Transforms/Transforms.h [new file with mode: 0644]
mlir/lib/Dialect/Affine/Transforms/AffineExpandIndexOps.cpp
mlir/lib/Dialect/Affine/Transforms/CMakeLists.txt
mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp [new file with mode: 0644]
mlir/test/Dialect/Affine/decompose-affine-ops.mlir [new file with mode: 0644]
mlir/test/lib/Dialect/Affine/CMakeLists.txt
mlir/test/lib/Dialect/Affine/TestDecomposeAffineOps.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/mlir-opt.cpp