[MLIR][Transform] Introduce loop.coalesce transform op.
authorAmy Wang <kai.ting.wang@huawei.com>
Tue, 17 Jan 2023 14:33:36 +0000 (09:33 -0500)
committerPrabhdeep Singh Soni <prabhdeep.singh.soni3@huawei.com>
Tue, 17 Jan 2023 14:38:47 +0000 (09:38 -0500)
commitefc0ba0275bd39fe0fb7548345139e9183fce20d
tree61893495c5e6380f29d58628283e2bc4654e70fa
parent123223ab87ca50d1ce4f8c08128d0237b3d31c84
[MLIR][Transform] Introduce loop.coalesce transform op.

This patch made a minor refactor of LoopCoalescing.cpp's walkLoops
templated method and placed it in Affine's LoopUtils.cpp/h.
This method is also renamed as coalescePerfectlyNestedLoops method. This
minor change enables this method to be invoked
by both the original LoopCoalescing pass as well as the newly introduced
loop.coalesce transform op.

The loop.coalesce transform op has the ability to coalesce affine, and
scf loop nests, leveraging existing LoopCoalescing
mechanism. I have created it inside the SCFTransformOps.td instead of
AffineTransformOps.td as it feels to be similar
in spirit as the loop.unroll op that can handle both scf and affine
loops. Please let me know if you feel that this op
should be moved into AffineTransformOps.td instead.

The testcase added illustrates loop.coalesce transform op working for
scf, affine loops (inner, outer) as well as
coalesced loop can be further unrolled (achieving composibility).

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D141202
mlir/include/mlir/Dialect/Affine/LoopUtils.h
mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
mlir/include/mlir/Dialect/SCF/Utils/Utils.h
mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp
mlir/lib/Dialect/SCF/Utils/Utils.cpp
mlir/test/Dialect/SCF/transform-op-coalesce.mlir [new file with mode: 0644]
mlir/test/Dialect/SCF/transform-ops-invalid.mlir [new file with mode: 0644]
mlir/test/Dialect/SCF/transform-ops.mlir