[Mlir-commits] [mlir] [mlir][Transforms] CSE: Add filter options to control CSE'ing (PR #115639)
Matthias Springer
llvmlistbot at llvm.org
Sun Nov 10 19:22:27 PST 2024
matthias-springer wrote:
Some context: In my use case, certain ops with regions should be a hoisting barrier for certain enclosed ops. CSE is one example of hoisting (by de-deduplication). Another one is the `GreedyPatternRewriteDriver`, which hoists constants.
I ran into this issue in the past when I was working on a transform dialect-based experiment in IREE: Ops without tensor results were allowed to be hoisted from a "dispatch region" op, but not ops with tensor results.
I just took a look at the `DialectFoldInterface` interface. It seems related but does not quite fit. The place where a constant is materialized is defined by the folded op (or its dialect to be precise). In my use case, it looks like I'd need the property (of being a hoisting barrier) on the region op, not the op that is going to be hoisted.
What could work is a `HoistingBarrierOpInterface` with an interface method `bool isBarrierFor(Operation *op)` with a default implementation of `return false`. In my use case, the region op would implement the interface and return "true" if `op` has a tensor result.
CSE and the greedy pattern driver could query that interface. Any thoughts?
https://github.com/llvm/llvm-project/pull/115639
More information about the Mlir-commits
mailing list