[Mlir-commits] [mlir] [mlir][transform] Use LoopInvariant passes in the tileConsumerAndFuseProducersUsingSCF (PR #163222)

lonely eagle llvmlistbot at llvm.org
Wed Oct 15 20:10:30 PDT 2025


linuxlonelyeagle wrote:

> Just to check: this change is mostly about hoisting of extract_slice, for `%extracted_slice_4` in the example of [#163222 (comment)](https://github.com/llvm/llvm-project/pull/163222#issuecomment-3398296959) ? And once the extract_slice is hoisted, the fill that is using it should also be hoisted by one loop.
> 
> If so, couldn't we just make use of the composability of transform ops and do:
> 
> ```
>   transform.named_sequence @__transform_main(
>        %arg0: !transform.any_op {transform.readonly}) {
>     %0 = transform.structured.match ops{["linalg.pooling_ncw_max"]} in %arg0 : (!transform.any_op) -> !transform.any_op
>     %tiled_pool, %loops:4 = transform.structured.fuse %0 {tile_sizes = [1, 16, 1, 1], apply_cleanup = true}
>       : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op)
>     transform.loop.hoist_loop_invariant_subsets %loops:4 : !transform.any_op // or %loops:1, whichever is the innermost loop
>     transform.apply_licm %loops:4 : !transform.any_op
>     transform.yield
>   }
> ```
> 
> Doesn't that already give you the desired result?

The example you provided does not resolve the issue. What you've done here is run loop-invariant passes against my IR above, but it doesn't work. This PR runs loop-invariant passes immediately after tiling, thereby correctly identifying the position for fuseOp insertion.

https://github.com/llvm/llvm-project/pull/163222


More information about the Mlir-commits mailing list