[Mlir-commits] [mlir] [mlir][scf] Extend consumer fusion to multiple tilable users (PR #111955)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Oct 12 19:11:56 PDT 2024
https://github.com/MaheshRavishankar requested changes to this pull request.
I see what you are trying to do here. But checking and bailing for this is very fragile. Essentially just based on the ordering of operations some fusion wont kick in, which is very hard to manage in general. Ideally the transformation itself should be able to move around operations to allow for the fusion to kick in.
The issue is that
```
... = firstUserOfLoop
... = defnOfConsumer
```
During transformation, the loop is moved just before the `defnOfConsumer` (note that it is unnecessary to say "lastDefOfConsumer", there is only one def). and this movement causes use-def chain violation.
I think a more robust approach is to move the `defOfConsumer` before `firstUserOfLoop`. Its fairly simple to do by
1) Check that `firstUserOfLoop` and `defnOfConsumer` are in the same block
2) Compute a backward slice of `defnOfConsumer` (with the op included) but cut the slice to not include any operation that `firstUserOfLoop` already dominates.
3) The first user of loop should not be in the slice computed. If it does, then bail/look for next consumer.
4) Move the slice computed (including `defnOfConsumer` before `firstUserOfLoop`.
The check that is included in this change is pretty complicated, but we probably dont want such checks. (In any case I thought a simple dominance check would work).
https://github.com/llvm/llvm-project/pull/111955
More information about the Mlir-commits
mailing list